@@ -6,6 +6,7 @@ from matplotlib import cbook
66from matplotlib .artist import Artist
77from matplotlib .axis import XAxis , YAxis , Tick
88from matplotlib .backend_bases import RendererBase , MouseButton , MouseEvent
9+ from matplotlib .cbook import CallbackRegistry
910from matplotlib .container import Container
1011from matplotlib .collections import Collection
1112from matplotlib .cm import ScalarMappable
@@ -25,9 +26,11 @@ from cycler import Cycler
2526
2627import numpy as np
2728from numpy .typing import ArrayLike
28- from typing import Any , Literal , overload
29+ from typing import Any , Literal , TypeVar , overload
2930from matplotlib .typing import ColorType
3031
32+ _T = TypeVar ("_T" , bound = Artist )
33+
3134class _axis_method_wrapper :
3235 attr_name : str
3336 method_name : str
@@ -53,6 +56,9 @@ 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 ]
5662 _projection_init : Any
5763
5864 def __init__ (
@@ -126,7 +132,7 @@ class _AxesBase(martist.Artist):
126132 def cla (self ) -> None : ...
127133
128134 # Could be made generic, but comments indicate it may be temporary anyway
129- class ArtistList (Sequence [Artist ]):
135+ class ArtistList (Sequence [_T ]):
130136 def __init__ (
131137 self ,
132138 axes : _AxesBase ,
@@ -135,40 +141,40 @@ class _AxesBase(martist.Artist):
135141 invalid_types : type | Iterable [type ] | None = ...,
136142 ) -> None : ...
137143 def __len__ (self ) -> int : ...
138- def __iter__ (self ) -> Iterator [Artist ]: ...
144+ def __iter__ (self ) -> Iterator [_T ]: ...
139145 @overload
140- def __getitem__ (self , key : int ) -> Artist : ...
146+ def __getitem__ (self , key : int ) -> _T : ...
141147 @overload
142- def __getitem__ (self , key : slice ) -> list [Artist ]: ...
148+ def __getitem__ (self , key : slice ) -> list [_T ]: ...
143149
144150 @overload
145- def __add__ (self , other : _AxesBase .ArtistList ) -> list [Artist ]: ...
151+ def __add__ (self , other : _AxesBase .ArtistList [ _T ] ) -> list [_T ]: ...
146152 @overload
147153 def __add__ (self , other : list [Any ]) -> list [Any ]: ...
148154 @overload
149155 def __add__ (self , other : tuple [Any ]) -> tuple [Any ]: ...
150156
151157 @overload
152- def __radd__ (self , other : _AxesBase .ArtistList ) -> list [Artist ]: ...
158+ def __radd__ (self , other : _AxesBase .ArtistList [ _T ] ) -> list [_T ]: ...
153159 @overload
154160 def __radd__ (self , other : list [Any ]) -> list [Any ]: ...
155161 @overload
156162 def __radd__ (self , other : tuple [Any ]) -> tuple [Any ]: ...
157163
158164 @property
159- def artists (self ) -> _AxesBase .ArtistList : ...
165+ def artists (self ) -> _AxesBase .ArtistList [ Artist ] : ...
160166 @property
161- def collections (self ) -> _AxesBase .ArtistList : ...
167+ def collections (self ) -> _AxesBase .ArtistList [ Collection ] : ...
162168 @property
163- def images (self ) -> _AxesBase .ArtistList : ...
169+ def images (self ) -> _AxesBase .ArtistList [ AxesImage ] : ...
164170 @property
165- def lines (self ) -> _AxesBase .ArtistList : ...
171+ def lines (self ) -> _AxesBase .ArtistList [ Line2D ] : ...
166172 @property
167- def patches (self ) -> _AxesBase .ArtistList : ...
173+ def patches (self ) -> _AxesBase .ArtistList [ Patch ] : ...
168174 @property
169- def tables (self ) -> _AxesBase .ArtistList : ...
175+ def tables (self ) -> _AxesBase .ArtistList [ Table ] : ...
170176 @property
171- def texts (self ) -> _AxesBase .ArtistList : ...
177+ def texts (self ) -> _AxesBase .ArtistList [ Text ] : ...
172178 def get_facecolor (self ) -> ColorType : ...
173179 def set_facecolor (self , color : ColorType | None ) -> None : ...
174180 @overload
0 commit comments