From 7aefebaa986649022c36e9a3917d2a1293875ac6 Mon Sep 17 00:00:00 2001 From: Randolf Scholz Date: Mon, 29 Jul 2024 20:02:21 +0200 Subject: [PATCH 1/3] added typing_extensions.Self to _AxesBase.twinx --- environment.yml | 1 + lib/matplotlib/axes/_base.pyi | 5 +++-- pyproject.toml | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/environment.yml b/environment.yml index 264f02800690..3ca4ca6b5050 100644 --- a/environment.yml +++ b/environment.yml @@ -28,6 +28,7 @@ dependencies: - python-dateutil>=2.1 - setuptools_scm - wxpython + - typing-extensions>=4.0.0 # building documentation - colorspacious - graphviz diff --git a/lib/matplotlib/axes/_base.pyi b/lib/matplotlib/axes/_base.pyi index 1fdc0750f0bc..4903bb41645e 100644 --- a/lib/matplotlib/axes/_base.pyi +++ b/lib/matplotlib/axes/_base.pyi @@ -27,6 +27,7 @@ from cycler import Cycler import numpy as np from numpy.typing import ArrayLike from typing import Any, Literal, TypeVar, overload +from typing_extensions import Self from matplotlib.typing import ColorType _T = TypeVar("_T", bound=Artist) @@ -384,8 +385,8 @@ class _AxesBase(martist.Artist): bbox_extra_artists: Sequence[Artist] | None = ..., for_layout_only: bool = ... ) -> Bbox | None: ... - def twinx(self) -> _AxesBase: ... - def twiny(self) -> _AxesBase: ... + def twinx(self) -> Self: ... + def twiny(self) -> Self: ... def get_shared_x_axes(self) -> cbook.GrouperView: ... def get_shared_y_axes(self) -> cbook.GrouperView: ... def label_outer(self, remove_inner_ticks: bool = ...) -> None: ... diff --git a/pyproject.toml b/pyproject.toml index 0f181ccb629e..b7663c968878 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ dependencies = [ "pillow >= 8", "pyparsing >= 2.3.1", "python-dateutil >= 2.7", + "typing-extensions >= 4.0.0", ] requires-python = ">=3.10" From 58e16b1ce9c0c6f7accd26528500f7e301e7da07 Mon Sep 17 00:00:00 2001 From: Randolf Scholz Date: Tue, 30 Jul 2024 11:31:20 +0200 Subject: [PATCH 2/3] removed dependency --- environment.yml | 1 - pyproject.toml | 1 - 2 files changed, 2 deletions(-) diff --git a/environment.yml b/environment.yml index 3ca4ca6b5050..264f02800690 100644 --- a/environment.yml +++ b/environment.yml @@ -28,7 +28,6 @@ dependencies: - python-dateutil>=2.1 - setuptools_scm - wxpython - - typing-extensions>=4.0.0 # building documentation - colorspacious - graphviz diff --git a/pyproject.toml b/pyproject.toml index b7663c968878..0f181ccb629e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,6 @@ dependencies = [ "pillow >= 8", "pyparsing >= 2.3.1", "python-dateutil >= 2.7", - "typing-extensions >= 4.0.0", ] requires-python = ">=3.10" From cf441b945f96659f565ec42fc2303ca7541eaa79 Mon Sep 17 00:00:00 2001 From: Randolf Scholz Date: Thu, 1 Aug 2024 14:28:21 +0200 Subject: [PATCH 3/3] use Axes instead of Self --- lib/matplotlib/axes/_base.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/axes/_base.pyi b/lib/matplotlib/axes/_base.pyi index 4903bb41645e..362d644d11f2 100644 --- a/lib/matplotlib/axes/_base.pyi +++ b/lib/matplotlib/axes/_base.pyi @@ -4,6 +4,7 @@ import datetime from collections.abc import Callable, Iterable, Iterator, Sequence from matplotlib import cbook from matplotlib.artist import Artist +from matplotlib.axes import Axes from matplotlib.axis import XAxis, YAxis, Tick from matplotlib.backend_bases import RendererBase, MouseButton, MouseEvent from matplotlib.cbook import CallbackRegistry @@ -27,7 +28,6 @@ from cycler import Cycler import numpy as np from numpy.typing import ArrayLike from typing import Any, Literal, TypeVar, overload -from typing_extensions import Self from matplotlib.typing import ColorType _T = TypeVar("_T", bound=Artist) @@ -385,8 +385,8 @@ class _AxesBase(martist.Artist): bbox_extra_artists: Sequence[Artist] | None = ..., for_layout_only: bool = ... ) -> Bbox | None: ... - def twinx(self) -> Self: ... - def twiny(self) -> Self: ... + def twinx(self) -> Axes: ... + def twiny(self) -> Axes: ... def get_shared_x_axes(self) -> cbook.GrouperView: ... def get_shared_y_axes(self) -> cbook.GrouperView: ... def label_outer(self, remove_inner_ticks: bool = ...) -> None: ...