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

Skip to content

Commit fa2304c

Browse files
committed
TYP: Fix return types of Gcf getters
Some return None when there is no figure available.
1 parent 7e5cc66 commit fa2304c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/matplotlib/_pylab_helpers.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ from matplotlib.figure import Figure
66
class Gcf:
77
figs: OrderedDict[int, FigureManagerBase]
88
@classmethod
9-
def get_fig_manager(cls, num: int) -> FigureManagerBase: ...
9+
def get_fig_manager(cls, num: int) -> FigureManagerBase | None: ...
1010
@classmethod
1111
def destroy(cls, num: int | FigureManagerBase) -> None: ...
1212
@classmethod
@@ -20,7 +20,9 @@ class Gcf:
2020
@classmethod
2121
def get_num_fig_managers(cls) -> int: ...
2222
@classmethod
23-
def get_active(cls) -> FigureManagerBase: ...
23+
def get_active(cls) -> FigureManagerBase | None: ...
24+
@classmethod
25+
def _set_new_active_manager(cls, manager: FigureManagerBase) -> None: ...
2426
@classmethod
2527
def set_active(cls, manager: FigureManagerBase) -> None: ...
2628
@classmethod

lib/matplotlib/pyplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ def figure(
938938

939939
for hookspecs in rcParams["figure.hooks"]:
940940
module_name, dotted_name = hookspecs.split(":")
941-
obj = importlib.import_module(module_name)
941+
obj: Any = importlib.import_module(module_name)
942942
for part in dotted_name.split("."):
943943
obj = getattr(obj, part)
944944
obj(fig)

0 commit comments

Comments
 (0)