Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc8bf5b

Browse files
authored
Merge pull request #27023 from meeseeksmachine/auto-backport-of-pr-26883-on-v3.8.x
Backport PR #26883 on branch v3.8.x ([TYP] Type changes from running against Pandas)
2 parents de99097 + cfdd720 commit fc8bf5b

File tree

3 files changed

+28
-18
lines changed

3 files changed

+28
-18
lines changed

lib/matplotlib/axes/__init__.pyi

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
from typing import TypeVar
22

3-
from ._axes import *
4-
from ._axes import Axes as Subplot
3+
from ._axes import Axes as Axes
4+
55

66
_T = TypeVar("_T")
77

8+
# Backcompat.
9+
Subplot = Axes
10+
811
class _SubplotBaseMeta(type):
912
def __instancecheck__(self, obj) -> bool: ...
1013

lib/matplotlib/axes/_base.pyi

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ from matplotlib import cbook
66
from matplotlib.artist import Artist
77
from matplotlib.axis import XAxis, YAxis, Tick
88
from matplotlib.backend_bases import RendererBase, MouseButton, MouseEvent
9+
from matplotlib.cbook import CallbackRegistry
910
from matplotlib.container import Container
1011
from matplotlib.collections import Collection
1112
from matplotlib.cm import ScalarMappable
@@ -25,9 +26,11 @@ from cycler import Cycler
2526

2627
import numpy as np
2728
from numpy.typing import ArrayLike
28-
from typing import Any, Literal, overload
29+
from typing import Any, Literal, TypeVar, overload
2930
from matplotlib.typing import ColorType
3031

32+
_T = TypeVar("_T", bound=Artist)
33+
3134
class _axis_method_wrapper:
3235
attr_name: str
3336
method_name: str
@@ -53,6 +56,11 @@ class _AxesBase(martist.Artist):
5356
transData: Transform
5457
ignore_existing_data_limits: bool
5558
axison: bool
59+
containers: list[Container]
60+
callbacks: CallbackRegistry
61+
child_axes: list[_AxesBase]
62+
legend_: Legend | None
63+
title: Text
5664
_projection_init: Any
5765

5866
def __init__(
@@ -125,8 +133,7 @@ class _AxesBase(martist.Artist):
125133
def clear(self) -> None: ...
126134
def cla(self) -> None: ...
127135

128-
# Could be made generic, but comments indicate it may be temporary anyway
129-
class ArtistList(Sequence[Artist]):
136+
class ArtistList(Sequence[_T]):
130137
def __init__(
131138
self,
132139
axes: _AxesBase,
@@ -135,40 +142,40 @@ class _AxesBase(martist.Artist):
135142
invalid_types: type | Iterable[type] | None = ...,
136143
) -> None: ...
137144
def __len__(self) -> int: ...
138-
def __iter__(self) -> Iterator[Artist]: ...
145+
def __iter__(self) -> Iterator[_T]: ...
139146
@overload
140-
def __getitem__(self, key: int) -> Artist: ...
147+
def __getitem__(self, key: int) -> _T: ...
141148
@overload
142-
def __getitem__(self, key: slice) -> list[Artist]: ...
149+
def __getitem__(self, key: slice) -> list[_T]: ...
143150

144151
@overload
145-
def __add__(self, other: _AxesBase.ArtistList) -> list[Artist]: ...
152+
def __add__(self, other: _AxesBase.ArtistList[_T]) -> list[_T]: ...
146153
@overload
147154
def __add__(self, other: list[Any]) -> list[Any]: ...
148155
@overload
149156
def __add__(self, other: tuple[Any]) -> tuple[Any]: ...
150157

151158
@overload
152-
def __radd__(self, other: _AxesBase.ArtistList) -> list[Artist]: ...
159+
def __radd__(self, other: _AxesBase.ArtistList[_T]) -> list[_T]: ...
153160
@overload
154161
def __radd__(self, other: list[Any]) -> list[Any]: ...
155162
@overload
156163
def __radd__(self, other: tuple[Any]) -> tuple[Any]: ...
157164

158165
@property
159-
def artists(self) -> _AxesBase.ArtistList: ...
166+
def artists(self) -> _AxesBase.ArtistList[Artist]: ...
160167
@property
161-
def collections(self) -> _AxesBase.ArtistList: ...
168+
def collections(self) -> _AxesBase.ArtistList[Collection]: ...
162169
@property
163-
def images(self) -> _AxesBase.ArtistList: ...
170+
def images(self) -> _AxesBase.ArtistList[AxesImage]: ...
164171
@property
165-
def lines(self) -> _AxesBase.ArtistList: ...
172+
def lines(self) -> _AxesBase.ArtistList[Line2D]: ...
166173
@property
167-
def patches(self) -> _AxesBase.ArtistList: ...
174+
def patches(self) -> _AxesBase.ArtistList[Patch]: ...
168175
@property
169-
def tables(self) -> _AxesBase.ArtistList: ...
176+
def tables(self) -> _AxesBase.ArtistList[Table]: ...
170177
@property
171-
def texts(self) -> _AxesBase.ArtistList: ...
178+
def texts(self) -> _AxesBase.ArtistList[Text]: ...
172179
def get_facecolor(self) -> ColorType: ...
173180
def set_facecolor(self, color: ColorType | None) -> None: ...
174181
@overload

lib/matplotlib/ticker.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class _DummyAxis:
1919

2020
class TickHelper:
2121
axis: None | Axis | _DummyAxis | _AxisWrapper
22-
def set_axis(self, axis: Axis | _DummyAxis | None) -> None: ...
22+
def set_axis(self, axis: Axis | _DummyAxis | _AxisWrapper | None) -> None: ...
2323
def create_dummy_axis(self, **kwargs) -> None: ...
2424

2525
class Formatter(TickHelper):

0 commit comments

Comments
 (0)