Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNT] fix type annotations of fignum_exists #27376

Merged
merged 3 commits into from
Nov 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 18 additions & 3 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,9 +999,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