##// END OF EJS Templates
_matplotlib_manages_backends uses hasattr not version check
Ian Thomas -
Show More
@@ -472,8 +472,27 b' def configure_inline_support(shell, backend):'
472 configure_inline_support_orig(shell, backend)
472 configure_inline_support_orig(shell, backend)
473
473
474
474
475 def _matplotlib_manages_backends():
475 # Determine if Matplotlib manages backends only if needed, and cache result.
476 import matplotlib
476 # Do not read this directly, instead use _matplotlib_manages_backends().
477 _matplotlib_manages_backends_value: bool | None = None
477
478
478 mpl_version_info = getattr(matplotlib, "__version_info__", (0, 0))
479
479 return mpl_version_info >= (3, 9)
480 def _matplotlib_manages_backends() -> bool:
481 """Return True if Matplotlib manages backends, False otherwise.
482
483 If it returns True, the caller can be sure that
484 matplotlib.backends.registry.backend_registry is available along with
485 member functions resolve_gui_or_backend, resolve_backend and list_all.
486 """
487 global _matplotlib_manages_backends_value
488 if _matplotlib_manages_backends_value is None:
489 try:
490 from matplotlib.backends.registry import backend_registry
491
492 _matplotlib_manages_backends_value = hasattr(
493 backend_registry, "resolve_gui_or_backend"
494 )
495 except ImportError:
496 _matplotlib_manages_backends_value = False
497
498 return _matplotlib_manages_backends_value
General Comments 0
You need to be logged in to leave comments. Login now