Skip to content

Commit

Permalink
Merge pull request #27379 from meeseeksmachine/auto-backport-of-pr-27…
Browse files Browse the repository at this point in the history
…376-on-v3.8.x

Backport PR #27376 on branch v3.8.x ([MNT] fix type annotations of `fignum_exists`)
  • Loading branch information
rcomer committed Nov 27, 2023
2 parents 9bc7420 + 696ac94 commit 25d096f
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,9 +1000,24 @@ def gcf() -> Figure:
return figure()


def fignum_exists(num: int) -> bool:
"""Return whether the figure with the given id exists."""
return _pylab_helpers.Gcf.has_fignum(num) or num in get_figlabels()
def fignum_exists(num: int | str) -> bool:
"""Return whether the figure with the given id exists.
Parameters
----------
num : int or str
A figure identifier.
Returns
-------
bool
Whether or not a figure with id *num* exists.
"""
return (
_pylab_helpers.Gcf.has_fignum(num)
if isinstance(num, int)
else num in get_figlabels()
)


def get_fignums() -> list[int]:
Expand Down

0 comments on commit 25d096f

Please sign in to comment.