8000 Change return type of `ion` and `ioff` to fix unbound variable errors with Pyright by FeldrinH · Pull Request #27667 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,11 @@ def isinteractive() -> bool:
return matplotlib.is_interactive()


def ioff() -> ExitStack:
# Note: The return type of ioff being AbstractContextManager
# instead of ExitStack is deliberate.
# See https://github.com/matplotlib/matplotlib/issues/27659
# and https://github.com/matplotlib/matplotlib/pull/27667 for more info.
def ioff() -> AbstractContextManager:
"""
Disable interactive mode.

Expand Down Expand Up @@ -586,7 +590,7 @@ def ioff() -> ExitStack:
# ...

To enable optional usage as a context manager, this function returns a
`~contextlib.ExitStack` object, which is not intended to be stored or
context manager object, which is not intended to be stored or
accessed by the user.
"""
stack = ExitStack()
Expand All @@ -596,7 +600,11 @@ def ioff() -> ExitStack:
return stack


def ion() -> ExitStack:
# Note: The return type of ion being AbstractContextManager
# instead of ExitStack is deliberate.
# See https://github.com/matplotlib/matplotlib/issues/27659
# and https://github.com/matplotlib/matplotlib/pull/27667 for more info.
def ion() -> AbstractContextManager:
"""
Enable interactive mode.

Expand Down Expand Up @@ -626,7 +634,7 @@ def ion() -> ExitStack:
# ...

To enable optional usage as a context manager, this function returns a
`~contextlib.ExitStack` object, which is not intended to be stored or
context manager object, which is not intended to be stored or
accessed by the user.
"""
stack = ExitStack()
Expand Down
0