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
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
Loading