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

Skip to content

Commit e2c9cd4

Browse files
sdieboltrcomer
andauthored
[MNT] fix type annotations of fignum_exists (#27376)
* fix: fix type annotations of `fignum_exists` * docs: expand documentation of `fignum_exists` * fix(docs): fix documentation of `fignum_exists` Co-authored-by: Ruth Comer <[email protected]> --------- Co-authored-by: Ruth Comer <[email protected]>
1 parent 3997ebb commit e2c9cd4

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
@@ -999,9 +999,24 @@ def gcf() -> Figure:
999999
return figure()
10001000

10011001

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

10061021

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

0 commit comments

Comments
 (0)