@@ -16,7 +16,7 @@ from matplotlib.colors import Colormap, Normalize
1616from matplotlib .colorbar import Colorbar
1717from matplotlib .cm import ScalarMappable
1818from matplotlib .gridspec import GridSpec , SubplotSpec
19- from matplotlib .image import _ImageBase
19+ from matplotlib .image import _ImageBase , FigureImage
2020from matplotlib .layout_engine import (
2121 ConstrainedLayoutEngine ,
2222 LayoutEngine ,
@@ -70,7 +70,10 @@ class SubplotParams:
7070 ) -> None : ...
7171
7272class FigureBase (Artist ):
73- figure : FigureBase | None
73+ # Small slight-of-hand as FigureBase is not instantiated directly
74+ # hinting as Figure means e.g. plt.figure can be type hinted more easily
75+ # FigureBase is never instantiated directly in internal code at the very least
76+ figure : Figure
7477 artists : list [Artist ]
7578 lines : list [Line2D ]
7679 patches : list [Patch ]
@@ -152,15 +155,15 @@ class FigureBase(Artist):
152155 * ,
153156 sharex : bool | Literal ["none" , "all" , "row" , "col" ] = ...,
154157 sharey : bool | Literal ["none" , "all" , "row" , "col" ] = ...,
155- squeeze : Literal [ True ] = ...,
158+ squeeze : bool = ...,
156159 width_ratios : ArrayLike | None = ...,
157160 height_ratios : ArrayLike | None = ...,
158161 subplot_kw : dict [str , Any ] | None = ...,
159162 gridspec_kw : dict [str , Any ] | None = ...
160163 ) -> np .ndarray | SubplotBase | Axes : ...
161164 def delaxes (self , ax : Axes ) -> None : ...
162165 def clear (self , keep_observers : bool = ...) -> None : ...
163- def clf (self , keep_observers : bool = ...): ...
166+ def clf (self , keep_observers : bool = ...) -> None : ...
164167
165168 @overload
166169 def legend (self ) -> Legend : ...
@@ -201,7 +204,7 @@ class FigureBase(Artist):
201204 def align_xlabels (self , axs : Iterable [Axes ] | None = ...) -> None : ...
202205 def align_ylabels (self , axs : Iterable [Axes ] | None = ...) -> None : ...
203206 def align_labels (self , axs : Iterable [Axes ] | None = ...) -> None : ...
204- def add_gridspec (self , nrows : int = ..., ncols : int = ..., ** kwargs ): ...
207+ def add_gridspec (self , nrows : int = ..., ncols : int = ..., ** kwargs ) -> GridSpec : ...
205208 @overload
206209 def subfigures (
207210 self ,
@@ -232,7 +235,7 @@ class FigureBase(Artist):
232235 def _gci (self ) -> ScalarMappable | None : ...
233236 def _process_projection_requirements (
234237 self , * args , axes_class = None , polar = False , projection = None , ** kwargs
235- ): ...
238+ ) -> tuple [ type [ Axes ], dict [ str , Any ]] : ...
236239 def get_default_bbox_extra_artists (self ) -> list [Artist ]: ...
237240 def get_tightbbox (
238241 self ,
@@ -256,7 +259,7 @@ class FigureBase(Artist):
256259 ) -> dict [Any , Axes ]: ...
257260
258261class SubFigure (FigureBase ):
259- figure : FigureBase
262+ figure : Figure
260263 subplotpars : SubplotParams
261264 dpi_scale_trans : Affine2D
262265 canvas : FigureCanvasBase
@@ -355,7 +358,7 @@ class Figure(FigureBase):
355358 origin : Literal ["upper" , "lower" ] | None = ...,
356359 resize : bool = ...,
357360 ** kwargs
358- ): ...
361+ ) -> FigureImage : ...
359362 def set_size_inches (
360363 self , w : float | tuple [float , float ], h : float | None = ..., forward : bool = ...
361364 ) -> None : ...
@@ -369,7 +372,7 @@ class Figure(FigureBase):
369372 def clear (self , keep_observers : bool = ...) -> None : ...
370373 def draw_without_rendering (self ) -> None : ...
371374 def draw_artist (self , a : Artist ) -> None : ...
372- def add_axobserver (self , func : Callable [[Figure ], Any ]): ...
375+ def add_axobserver (self , func : Callable [[Figure ], Any ]) -> None : ...
373376 def savefig (
374377 self ,
375378 fname : str | os .PathLike | io .FileIO ,
@@ -386,7 +389,7 @@ class Figure(FigureBase):
386389 mouse_pop : MouseButton = ...,
387390 mouse_stop : MouseButton = ...,
388391 ) -> list [tuple [int , int ]]: ...
389- def waitforbuttonpress (self , timeout : float = ...): ...
392+ def waitforbuttonpress (self , timeout : float = ...) -> None | bool : ...
390393 def tight_layout (
391394 self ,
392395 * ,
0 commit comments