@@ -6,6 +6,7 @@ from matplotlib import cbook
6
6
from matplotlib .artist import Artist
7
7
from matplotlib .axis import XAxis , YAxis , Tick
8
8
from matplotlib .backend_bases import RendererBase , MouseButton , MouseEvent
9
+ from matplotlib .cbook import CallbackRegistry
9
10
from matplotlib .container import Container
10
11
from matplotlib .collections import Collection
11
12
from matplotlib .cm import ScalarMappable
@@ -25,9 +26,11 @@ from cycler import Cycler
25
26
26
27
import numpy as np
27
28
from numpy .typing import ArrayLike
28
- from typing import Any , Literal , overload
29
+ from typing import Any , Literal , TypeVar , overload
29
30
from matplotlib .typing import ColorType
30
31
32
+ _T = TypeVar ("_T" , bound = Artist )
33
+
31
34
class _axis_method_wrapper :
32
35
attr_name : str
33
36
method_name : str
@@ -53,6 +56,11 @@ class _AxesBase(martist.Artist):
53
56
transData : Transform
54
57
ignore_existing_data_limits : bool
55
58
axison : bool
59
+ containers : list [Container ]
60
+ callbacks : CallbackRegistry
61
+ child_axes : list [_AxesBase ]
62
+ legend_ : Legend | None
63
+ title : Text
56
64
_projection_init : Any
57
65
58
66
def __init__ (
@@ -125,8 +133,7 @@ class _AxesBase(martist.Artist):
125
133
def clear (self ) -> None : ...
126
134
def cla (self ) -> None : ...
127
135
128
- # Could be made generic, but comments indicate it may be temporary anyway
129
- class ArtistList (Sequence [Artist ]):
136
+ class ArtistList (Sequence [_T ]):
130
137
def __init__ (
131
138
self ,
132
139
axes : _AxesBase ,
@@ -135,40 +142,40 @@ class _AxesBase(martist.Artist):
135
142
invalid_types : type | Iterable [type ] | None = ...,
136
143
) -> None : ...
137
144
def __len__ (self ) -> int : ...
138
- def __iter__ (self ) -> Iterator [Artist ]: ...
145
+ def __iter__ (self ) -> Iterator [_T ]: ...
139
146
@overload
140
- def __getitem__ (self , key : int ) -> Artist : ...
147
+ def __getitem__ (self , key : int ) -> _T : ...
141
148
@overload
142
- def __getitem__ (self , key : slice ) -> list [Artist ]: ...
149
+ def __getitem__ (self , key : slice ) -> list [_T ]: ...
143
150
144
151
@overload
145
- def __add__ (self , other : _AxesBase .ArtistList ) -> list [Artist ]: ...
152
+ def __add__ (self , other : _AxesBase .ArtistList [ _T ] ) -> list [_T ]: ...
146
153
@overload
147
154
def __add__ (self , other : list [Any ]) -> list [Any ]: ...
148
155
@overload
149
156
def __add__ (self , other : tuple [Any ]) -> tuple [Any ]: ...
150
157
151
158
@overload
152
- def __radd__ (self , other : _AxesBase .ArtistList ) -> list [Artist ]: ...
159
+ def __radd__ (self , other : _AxesBase .ArtistList [ _T ] ) -> list [_T ]: ...
153
160
@overload
154
161
def __radd__ (self , other : list [Any ]) -> list [Any ]: ...
155
162
@overload
156
163
def __radd__ (self , other : tuple [Any ]) -> tuple [Any ]: ...
157
164
158
165
@property
159
- def artists (self ) -> _AxesBase .ArtistList : ...
166
+ def artists (self ) -> _AxesBase .ArtistList [ Artist ] : ...
160
167
@property
161
- def collections (self ) -> _AxesBase .ArtistList : ...
168
+ def collections (self ) -> _AxesBase .ArtistList [ Collection ] : ...
162
169
@property
163
- def images (self ) -> _AxesBase .ArtistList : ...
170
+ def images (self ) -> _AxesBase .ArtistList [ AxesImage ] : ...
164
171
@property
165
- def lines (self ) -> _AxesBase .ArtistList : ...
172
+ def lines (self ) -> _AxesBase .ArtistList [ Line2D ] : ...
166
173
@property
167
- def patches (self ) -> _AxesBase .ArtistList : ...
174
+ def patches (self ) -> _AxesBase .ArtistList [ Patch ] : ...
168
175
@property
169
- def tables (self ) -> _AxesBase .ArtistList : ...
176
+ def tables (self ) -> _AxesBase .ArtistList [ Table ] : ...
170
177
@property
171
- def texts (self ) -> _AxesBase .ArtistList : ...
178
+ def texts (self ) -> _AxesBase .ArtistList [ Text ] : ...
172
179
def get_facecolor (self ) -> ColorType : ...
173
180
def set_facecolor (self , color : ColorType | None ) -> None : ...
174
181
@overload
0 commit comments