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

Handle new matplotlib versions #1791

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
22 changes: 21 additions & 1 deletion src/debugpy/_vendored/pydevd/pydev_ipython/matplotlibtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,30 @@ def find_gui_and_backend():
return gui, backend


def _get_major_version(module):
return int(module.__version__.split('.')[0])


def _get_minor_version(module):
return int(module.__version__.split('.')[1])


def is_interactive_backend(backend):
"""Check if backend is interactive"""
matplotlib = sys.modules["matplotlib"]
from matplotlib.rcsetup import interactive_bk, non_interactive_bk # @UnresolvedImport
new_api_version = (3, 9)
installed_version = (
_get_major_version(matplotlib),
_get_minor_version(matplotlib)
)

if installed_version >= new_api_version:
interactive_bk = matplotlib.backends.backend_registry.list_builtin(
matplotlib.backends.BackendFilter.INTERACTIVE)
non_interactive_bk = matplotlib.backends.backend_registry.list_builtin(
matplotlib.backends.BackendFilter.NON_INTERACTIVE)
else:
from matplotlib.rcsetup import interactive_bk, non_interactive_bk # @UnresolvedImport

if backend in interactive_bk:
return True
Expand Down