Skip to content

Commit

Permalink
Handle new matplotlib versions (#1791)
Browse files Browse the repository at this point in the history
Fixes: #1623
  • Loading branch information
garymm authored Jan 6, 2025
1 parent 24aa6a5 commit cc85ca8
Showing 1 changed file with 21 additions and 1 deletion.
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

0 comments on commit cc85ca8

Please sign in to comment.