diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5d06d98e..b2125a1a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,12 +8,12 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/PyCQA/flake8 - rev: 4.0.1 + rev: 7.0.0 hooks: - id: flake8 - additional_dependencies: [flake8-typing-imports==1.7.0] + additional_dependencies: [flake8-typing-imports==1.15.0] - repo: https://github.com/myint/autoflake - rev: v1.4 + rev: v2.3.0 hooks: - id: autoflake args: ["--in-place", "--remove-all-unused-imports", "--ignore-init-module-imports", "--remove-unused-variables"] diff --git a/ipympl/backend_nbagg.py b/ipympl/backend_nbagg.py index cd098190..45dde922 100644 --- a/ipympl/backend_nbagg.py +++ b/ipympl/backend_nbagg.py @@ -540,7 +540,8 @@ def show(block=None): def flush_figures(): - if rcParams['backend'] == 'module://ipympl.backend_nbagg': + backend = matplotlib.get_backend() + if backend in ('widget', 'ipympl', 'module://ipympl.backend_nbagg'): if not _Backend_ipympl._draw_called: return diff --git a/pyproject.toml b/pyproject.toml index 020bfb29..1d3bd41c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ dependencies = [ "traitlets<6", ] requires-python = ">=3.9" -version = "0.9.3" +version = "0.9.4.dev1" [project.optional-dependencies] docs = [ @@ -66,6 +66,10 @@ docs = [ Homepage = "http://matplotlib.org/ipympl" Repository = "https://github.com/matplotlib/ipympl" +[project.entry-points."matplotlib.backend"] +ipympl = "ipympl.backend_nbagg" +widget = "ipympl.backend_nbagg" + [tool.hatch.build] artifacts = [ "ipympl/nbextension/index.*", diff --git a/tests/test_entry_points.py b/tests/test_entry_points.py new file mode 100644 index 00000000..61d4a733 --- /dev/null +++ b/tests/test_entry_points.py @@ -0,0 +1,11 @@ +def test_own_entry_points(): + from importlib_metadata import entry_points + + entries = entry_points(group="matplotlib.backend") + for name in ["ipympl", "widget"]: + assert name in entries.names + entry = entries[name] + assert entry.name == name + assert entry.value == "ipympl.backend_nbagg" + # Check can load module. + entry.load()