Skip to content

Commit 25d096f

Browse files
authored
Merge pull request matplotlib#27379 from meeseeksmachine/auto-backport-of-pr-27376-on-v3.8.x
Backport PR matplotlib#27376 on branch v3.8.x ([MNT] fix type annotations of `fignum_exists`)
2 parents 9bc7420 + 696ac94 commit 25d096f

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

lib/matplotlib/pyplot.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,9 +1000,24 @@ def gcf() -> Figure:
10001000
return figure()
10011001

10021002

1003-
def fignum_exists(num: int) -> bool:
1004-
"""Return whether the figure with the given id exists."""
1005-
return _pylab_helpers.Gcf.has_fignum(num) or num in get_figlabels()
1003+
def fignum_exists(num: int | str) -> bool:
1004+
"""Return whether the figure with the given id exists.
1005+
1006+
Parameters
1007+
----------
1008+
num : int or str
1009+
A figure identifier.
1010+
1011+
Returns
1012+
-------
1013+
bool
1014+
Whether or not a figure with id *num* exists.
1015+
"""
1016+
return (
1017+
_pylab_helpers.Gcf.has_fignum(num)
1018+
if isinstance(num, int)
1019+
else num in get_figlabels()
1020+
)
10061021

10071022

10081023
def get_fignums() -> list[int]:

0 commit comments

Comments
 (0)