From ae412cb24421c9b18e9a1b92317844bdfa191290 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 17:29:12 +0000 Subject: [PATCH 01/29] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.11 → v0.1.14](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.11...v0.1.14) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8df635a..9f84305 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.1.11' + rev: 'v0.1.14' hooks: - id: ruff From 266f4849136a4b11be6d4b27dffb886058e3cf2e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 17:32:20 +0000 Subject: [PATCH 02/29] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.12.1 → 24.1.1](https://github.com/psf/black/compare/23.12.1...24.1.1) - [github.com/astral-sh/ruff-pre-commit: v0.1.14 → v0.2.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.14...v0.2.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9f84305..5bff103 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black @@ -24,7 +24,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.1.14' + rev: 'v0.2.0' hooks: - id: ruff From 0efd2b2c03e3dcc1cd455489af5a1fc813527935 Mon Sep 17 00:00:00 2001 From: Sam Cunliffe Date: Tue, 6 Feb 2024 19:31:50 +0000 Subject: [PATCH 03/29] Expecting two warnings so nested with pytest.warns. --- src/napari_matplotlib/tests/test_util.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/napari_matplotlib/tests/test_util.py b/src/napari_matplotlib/tests/test_util.py index a8792d4..918e763 100644 --- a/src/napari_matplotlib/tests/test_util.py +++ b/src/napari_matplotlib/tests/test_util.py @@ -69,7 +69,10 @@ def test_fallback_if_missing_dimensions(mocker): test_css = " Flobble { background-color: rgb(0, 97, 163); } " mocker.patch("napari.qt.get_current_stylesheet").return_value = test_css with pytest.warns(RuntimeWarning, match="Unable to find DimensionToken"): - assert from_napari_css_get_size_of("Flobble", (1, 2)) == QSize(1, 2) + with pytest.warns(RuntimeWarning, match="Unable to find Flobble"): + assert from_napari_css_get_size_of("Flobble", (1, 2)) == QSize( + 1, 2 + ) def test_fallback_if_prelude_not_in_css(): From cd429ee947b9e8dc949851bab0ef106d157b0531 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 7 Feb 2024 09:45:06 +0000 Subject: [PATCH 04/29] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- examples/histogram.py | 1 + examples/scatter.py | 1 + examples/slice.py | 1 + 3 files changed, 3 insertions(+) diff --git a/examples/histogram.py b/examples/histogram.py index ccda491..b9ceb37 100644 --- a/examples/histogram.py +++ b/examples/histogram.py @@ -2,6 +2,7 @@ Histograms ========== """ + import napari viewer = napari.Viewer() diff --git a/examples/scatter.py b/examples/scatter.py index cd81240..00e01ec 100644 --- a/examples/scatter.py +++ b/examples/scatter.py @@ -2,6 +2,7 @@ Scatter plots ============= """ + import napari viewer = napari.Viewer() diff --git a/examples/slice.py b/examples/slice.py index 3e43443..242a16c 100644 --- a/examples/slice.py +++ b/examples/slice.py @@ -2,6 +2,7 @@ 1D slices ========= """ + import napari viewer = napari.Viewer() From 07217c621302d644a8796e878cf70bfdde2f2164 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 17:33:44 +0000 Subject: [PATCH 05/29] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.2.0 → v0.2.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.0...v0.2.1) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5bff103..f97ded2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.2.0' + rev: 'v0.2.1' hooks: - id: ruff From 46058eea210c3b7c532d0e857f05592e15568de5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 17:43:22 +0000 Subject: [PATCH 06/29] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 24.1.1 → 24.2.0](https://github.com/psf/black/compare/24.1.1...24.2.0) - [github.com/astral-sh/ruff-pre-commit: v0.2.1 → v0.2.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.1...v0.2.2) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f97ded2..e57a9c8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/psf/black - rev: 24.1.1 + rev: 24.2.0 hooks: - id: black @@ -24,7 +24,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.2.1' + rev: 'v0.2.2' hooks: - id: ruff From 517b2139ccfe59a4cc486467692a0e62bb9839aa Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 3 May 2024 15:21:40 +0100 Subject: [PATCH 07/29] Update pre-commit --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e57a9c8..40048ea 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,13 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-docstring-first - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/psf/black - rev: 24.2.0 + rev: 24.4.2 hooks: - id: black @@ -17,14 +17,14 @@ repos: - id: napari-plugin-checks - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.8.0 + rev: v1.10.0 hooks: - id: mypy additional_dependencies: [numpy, matplotlib] - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.2.2' + rev: 'v0.4.2' hooks: - id: ruff From 9949427de3b7212931e2601baabf2040c7cbfe22 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 3 May 2024 15:36:11 +0100 Subject: [PATCH 08/29] Bump codecov action --- .github/workflows/test_and_deploy.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 8665e1d..9b24e7f 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -58,7 +58,7 @@ jobs: if: ${{ always() }} - name: Coverage - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 # Don't run coverage on merge queue CI to avoid duplicating reports # to codecov. See https://github.com/matplotlib/napari-matplotlib/issues/155 if: github.event_name != 'merge_group' @@ -66,6 +66,8 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true + + deploy: # this will run when you have tagged a commit, starting with "v*" # and requires that you have put your twine API key in your From ea21e54a0c30ceafb3b7c1bdbf7e9ab77f8629c7 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 3 May 2024 15:47:12 +0100 Subject: [PATCH 09/29] Suppress doc build warning --- docs/conf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index 2517a59..5be3c95 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -33,6 +33,7 @@ "sphinx_automodapi.automodapi", "sphinx_automodapi.smart_resolver", "sphinx.ext.intersphinx", + "qtgallery", ] sphinx_gallery_conf = { @@ -40,6 +41,7 @@ "image_scrapers": (qtgallery.qtscraper,), "reset_modules": (qtgallery.reset_qapp,), } +suppress_warnings = ["config.cache"] qtgallery_conf = { "xvfb_size": (640, 480), From 2645f43d139202da084aba3cecaa5b19f762093b Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 3 May 2024 15:54:05 +0100 Subject: [PATCH 10/29] Remove napari hub preview --- .github/workflows/napari_hub_preview.yml | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 .github/workflows/napari_hub_preview.yml diff --git a/.github/workflows/napari_hub_preview.yml b/.github/workflows/napari_hub_preview.yml deleted file mode 100644 index c204ac4..0000000 --- a/.github/workflows/napari_hub_preview.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: napari hub Preview Page # we use this name to find your preview page artifact, so don't change it! -# For more info on this action, see https://github.com/chanzuckerberg/napari-hub-preview-action/blob/main/action.yml - -on: - pull_request: - types: [ labeled ] - -jobs: - preview-page: - if: ${{ github.event.label.name == 'napari hub preview' }} - name: Preview Page Deploy - runs-on: ubuntu-latest - - steps: - - name: Checkout repo - uses: actions/checkout@v3 - - - name: napari hub Preview Page Builder - uses: chanzuckerberg/napari-hub-preview-action@v0.1 - with: - hub-ref: main From e5b9bb2b5bf5b00aaf0fcbf5598a235b08fd9c83 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 3 May 2024 15:54:42 +0100 Subject: [PATCH 11/29] Update headless gui version --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 5b721d9..39c1ab5 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -32,7 +32,7 @@ jobs: sudo apt install graphviz --yes - name: Build Docs - uses: aganders3/headless-gui@v1 + uses: aganders3/headless-gui@v2 with: run: make html working-directory: ./docs From 8cc74cab748cc0da54e6c08ea52d8d0a119fee79 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 3 May 2024 16:01:03 +0100 Subject: [PATCH 12/29] Try stable release of napari for doc build --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 41e4e34..25aa4cf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -47,7 +47,7 @@ napari.manifest = [options.extras_require] docs = - napari[all]==0.4.19rc3 + napari[all]==0.4.19 numpydoc pydantic<2 pydata-sphinx-theme From 0be3f7b70c60fd8cd44220ab4f1c6bfe24722770 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 3 May 2024 16:10:26 +0100 Subject: [PATCH 13/29] Remoe doc napari pin --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 25aa4cf..cccec1c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -47,7 +47,7 @@ napari.manifest = [options.extras_require] docs = - napari[all]==0.4.19 + napari[all] numpydoc pydantic<2 pydata-sphinx-theme From 797e4605e99e2773f9ebcbe5ddd0f687e316fb6e Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 24 May 2024 14:00:28 +0100 Subject: [PATCH 14/29] Try custom scrapers --- docs/conf.py | 57 +++++++++++++++++++++++++++++++++++++++++++--------- setup.cfg | 1 - 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 5be3c95..3c6ce6f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -13,7 +13,7 @@ # import os # import sys # sys.path.insert(0, os.path.abspath('.')) -import qtgallery +from sphinx_gallery import scrapers # -- Project information ----------------------------------------------------- @@ -33,22 +33,59 @@ "sphinx_automodapi.automodapi", "sphinx_automodapi.smart_resolver", "sphinx.ext.intersphinx", - "qtgallery", ] + +def reset_napari(gallery_conf, fname): + from napari.settings import get_settings + from qtpy.QtWidgets import QApplication + + settings = get_settings() + settings.appearance.theme = "dark" + + # Disabling `QApplication.exec_` means example scripts can call `exec_` + # (scripts work when run normally) without blocking example execution by + # sphinx-gallery. (from qtgallery) + QApplication.exec_ = lambda _: None + + +def napari_scraper(block, block_vars, gallery_conf): + """Basic napari window scraper. + + Looks for any QtMainWindow instances and takes a screenshot of them. + + `app.processEvents()` allows Qt events to propagateo and prevents hanging. + """ + import napari + + imgpath_iter = block_vars["image_path_iterator"] + + if app := napari.qt.get_app(): + app.processEvents() + else: + return "" + + img_paths = [] + for win, img_path in zip( + reversed(napari._qt.qt_main_window._QtMainWindow._instances), + imgpath_iter, + ): + img_paths.append(img_path) + win._window.screenshot(img_path, canvas_only=False) + + napari.Viewer.close_all() + app.processEvents() + + return scrapers.figure_rst(img_paths, gallery_conf["src_dir"]) + + sphinx_gallery_conf = { "filename_pattern": ".", - "image_scrapers": (qtgallery.qtscraper,), - "reset_modules": (qtgallery.reset_qapp,), + "image_scrapers": (napari_scraper,), + "reset_modules": (reset_napari,), } suppress_warnings = ["config.cache"] -qtgallery_conf = { - "xvfb_size": (640, 480), - "xvfb_color_depth": 24, - "xfvb_use_xauth": False, - "xfvb_extra_args": [], -} numpydoc_show_class_members = False automodapi_inheritance_diagram = True diff --git a/setup.cfg b/setup.cfg index cccec1c..76fc8bf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -51,7 +51,6 @@ docs = numpydoc pydantic<2 pydata-sphinx-theme - qtgallery sphinx sphinx-automodapi sphinx-gallery From 312d50c03bd9e4df775c6baa17d728affe37658b Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 24 May 2024 14:03:57 +0100 Subject: [PATCH 15/29] Add some type ignores --- docs/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 3c6ce6f..2818f02 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -36,7 +36,7 @@ ] -def reset_napari(gallery_conf, fname): +def reset_napari(gallery_conf, fname): # type: ignore[no-untyped-def] from napari.settings import get_settings from qtpy.QtWidgets import QApplication @@ -49,7 +49,7 @@ def reset_napari(gallery_conf, fname): QApplication.exec_ = lambda _: None -def napari_scraper(block, block_vars, gallery_conf): +def napari_scraper(block, block_vars, gallery_conf): # type: ignore[no-untyped-def] """Basic napari window scraper. Looks for any QtMainWindow instances and takes a screenshot of them. From 5c80464405f4c5205628805911c33ef9bf0e1226 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 3 May 2024 15:27:26 +0100 Subject: [PATCH 16/29] Adhere to SPEC0 --- .github/workflows/test_and_deploy.yml | 2 +- docs/changelog.rst | 9 +++++++++ pyproject.toml | 4 ++-- setup.cfg | 4 ++-- tox.ini | 4 ++-- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 9b24e7f..94cf1e9 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -20,7 +20,7 @@ jobs: fail-fast: false matrix: platform: [ubuntu-latest, macos-latest, windows-latest] - python-version: ['3.9', '3.10', '3.11'] + python-version: ['3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v3 diff --git a/docs/changelog.rst b/docs/changelog.rst index 255982a..8e3e859 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,5 +1,14 @@ Changelog ========= +2.0.2 +----- +Dependencies +~~~~~~~~~~~~ +napari-matplotlib now adheres to `SPEC 0`_, and has: +- Dropped support for Python 3.9 +- Added support for Python 3.12 +- Added a minimum required numpy verison of 1.23 + 2.0.1 ----- Bug fixes diff --git a/pyproject.toml b/pyproject.toml index ba9f9e6..d569113 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ profile = "black" line_length = 79 [tool.ruff] -target-version = "py39" +target-version = "py310" select = ["I", "UP", "F", "E", "W", "D"] ignore = [ "D100", # Missing docstring in public module @@ -46,7 +46,7 @@ fix = true convention = "numpy" [tool.mypy] -python_version = "3.9" +python_version = "3.10" # Block below are checks that form part of mypy 'strict' mode strict = true disallow_subclassing_any = false # TODO: fix diff --git a/setup.cfg b/setup.cfg index 76fc8bf..2b74504 100644 --- a/setup.cfg +++ b/setup.cfg @@ -29,9 +29,9 @@ packages = find: install_requires = matplotlib napari - numpy + numpy>=1.23 tinycss2 -python_requires = >=3.9 +python_requires = >=3.10 include_package_data = True package_dir = =src diff --git a/tox.ini b/tox.ini index 4ec0c70..f4aed6a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,12 @@ [tox] -envlist = py{39,310,311} +envlist = py{310,311,312} isolated_build = true [gh-actions] python = - 3.9: py39 3.10: py310 3.11: py311 + 3.12: py312 [testenv] extras = testing From 891f4aa263e1d08dccd22e27f7b00941cf076268 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 24 May 2024 14:17:39 +0100 Subject: [PATCH 17/29] Ignore pydantic warning --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index d569113..bbec409 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,8 @@ filterwarnings = [ # Coming from vispy "ignore:distutils Version classes are deprecated:DeprecationWarning", "ignore:`np.bool8` is a deprecated alias for `np.bool_`:DeprecationWarning", + # Coming from pydantic via napari + "ignore:Pickle, copy, and deepcopy support will be removed from itertools in Python 3.14.:DeprecationWarning" ] qt_api = "pyqt6" addopts = "--mpl --mpl-baseline-relative" From 52bb0a902bc4c427f159a7ab4e4f2b969d33169b Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 24 May 2024 14:40:06 +0100 Subject: [PATCH 18/29] pre-commit fixes --- src/napari_matplotlib/base.py | 7 +++---- src/napari_matplotlib/histogram.py | 12 ++++++------ src/napari_matplotlib/scatter.py | 8 ++++---- src/napari_matplotlib/slice.py | 4 ++-- src/napari_matplotlib/util.py | 9 +++------ 5 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/napari_matplotlib/base.py b/src/napari_matplotlib/base.py index fb9e485..c455335 100644 --- a/src/napari_matplotlib/base.py +++ b/src/napari_matplotlib/base.py @@ -1,6 +1,5 @@ import os from pathlib import Path -from typing import Optional import matplotlib.style as mplstyle import napari @@ -38,7 +37,7 @@ class BaseNapariMPLWidget(QWidget): def __init__( self, napari_viewer: napari.Viewer, - parent: Optional[QWidget] = None, + parent: QWidget | None = None, ): super().__init__(parent=parent) self.viewer = napari_viewer @@ -173,7 +172,7 @@ class NapariMPLWidget(BaseNapariMPLWidget): def __init__( self, napari_viewer: napari.viewer.Viewer, - parent: Optional[QWidget] = None, + parent: QWidget | None = None, ): super().__init__(napari_viewer=napari_viewer, parent=parent) self._setup_callbacks() @@ -282,7 +281,7 @@ class SingleAxesWidget(NapariMPLWidget): def __init__( self, napari_viewer: napari.viewer.Viewer, - parent: Optional[QWidget] = None, + parent: QWidget | None = None, ): super().__init__(napari_viewer=napari_viewer, parent=parent) self.add_single_axes() diff --git a/src/napari_matplotlib/histogram.py b/src/napari_matplotlib/histogram.py index 4076528..a0b6e09 100644 --- a/src/napari_matplotlib/histogram.py +++ b/src/napari_matplotlib/histogram.py @@ -1,4 +1,4 @@ -from typing import Any, Optional, cast +from typing import Any, cast import napari import numpy as np @@ -44,7 +44,7 @@ class HistogramWidget(SingleAxesWidget): def __init__( self, napari_viewer: napari.viewer.Viewer, - parent: Optional[QWidget] = None, + parent: QWidget | None = None, ): super().__init__(napari_viewer, parent=parent) self._update_layers(None) @@ -121,7 +121,7 @@ class FeaturesHistogramWidget(SingleAxesWidget): def __init__( self, napari_viewer: napari.viewer.Viewer, - parent: Optional[QWidget] = None, + parent: QWidget | None = None, ): super().__init__(napari_viewer, parent=parent) @@ -137,12 +137,12 @@ def __init__( self._update_layers(None) @property - def x_axis_key(self) -> Optional[str]: + def x_axis_key(self) -> str | None: """Key to access x axis data from the FeaturesTable""" return self._x_axis_key @x_axis_key.setter - def x_axis_key(self, key: Optional[str]) -> None: + def x_axis_key(self, key: str | None) -> None: self._x_axis_key = key self._draw() @@ -166,7 +166,7 @@ def _get_valid_axis_keys(self) -> list[str]: else: return self.layers[0].features.keys() - def _get_data(self) -> tuple[Optional[npt.NDArray[Any]], str]: + def _get_data(self) -> tuple[npt.NDArray[Any] | None, str]: """Get the plot data. Returns diff --git a/src/napari_matplotlib/scatter.py b/src/napari_matplotlib/scatter.py index 67d6896..98ebe92 100644 --- a/src/napari_matplotlib/scatter.py +++ b/src/napari_matplotlib/scatter.py @@ -1,4 +1,4 @@ -from typing import Any, Optional, Union +from typing import Any import napari import numpy.typing as npt @@ -100,7 +100,7 @@ class FeaturesScatterWidget(ScatterBaseWidget): def __init__( self, napari_viewer: napari.viewer.Viewer, - parent: Optional[QWidget] = None, + parent: QWidget | None = None, ): super().__init__(napari_viewer, parent=parent) @@ -118,7 +118,7 @@ def __init__( self._update_layers(None) @property - def x_axis_key(self) -> Union[str, None]: + def x_axis_key(self) -> str | None: """ Key for the x-axis data. """ @@ -133,7 +133,7 @@ def x_axis_key(self, key: str) -> None: self._draw() @property - def y_axis_key(self) -> Union[str, None]: + def y_axis_key(self) -> str | None: """ Key for the y-axis data. """ diff --git a/src/napari_matplotlib/slice.py b/src/napari_matplotlib/slice.py index 9459fa9..1924bf2 100644 --- a/src/napari_matplotlib/slice.py +++ b/src/napari_matplotlib/slice.py @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any import matplotlib.ticker as mticker import napari @@ -30,7 +30,7 @@ class SliceWidget(SingleAxesWidget): def __init__( self, napari_viewer: napari.viewer.Viewer, - parent: Optional[QWidget] = None, + parent: QWidget | None = None, ): # Setup figure/axes super().__init__(napari_viewer, parent=parent) diff --git a/src/napari_matplotlib/util.py b/src/napari_matplotlib/util.py index ed99425..c54b60a 100644 --- a/src/napari_matplotlib/util.py +++ b/src/napari_matplotlib/util.py @@ -1,4 +1,3 @@ -from typing import Optional, Union from warnings import warn import napari.qt @@ -12,7 +11,7 @@ class Interval: An integer interval. """ - def __init__(self, lower_bound: Optional[int], upper_bound: Optional[int]): + def __init__(self, lower_bound: int | None, upper_bound: int | None): """ Parameters ---------- @@ -48,7 +47,7 @@ def __contains__(self, val: int) -> bool: return True @property - def _helper_text(self) -> Optional[str]: + def _helper_text(self) -> str | None: """ Helper text for widgets. """ @@ -86,9 +85,7 @@ def _has_id(nodes: list[tinycss2.ast.Node], id_name: str) -> bool: ) -def _get_dimension( - nodes: list[tinycss2.ast.Node], id_name: str -) -> Union[int, None]: +def _get_dimension(nodes: list[tinycss2.ast.Node], id_name: str) -> int | None: """ Get the value of the DimensionToken for the IdentToken `id_name`. From e7c49451e5e1b25ccef43ddba054ad4a23328e99 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 24 May 2024 14:43:04 +0100 Subject: [PATCH 19/29] Fix doc link --- docs/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 8e3e859..ff2e60c 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,7 +4,7 @@ Changelog ----- Dependencies ~~~~~~~~~~~~ -napari-matplotlib now adheres to `SPEC 0`_, and has: +napari-matplotlib now adheres to `SPEC 0 `_, and has: - Dropped support for Python 3.9 - Added support for Python 3.12 - Added a minimum required numpy verison of 1.23 From 1818110f3a04f9948b28ca789dd34eb7e7369674 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 24 May 2024 14:46:43 +0100 Subject: [PATCH 20/29] Don't fail if codecov fails --- .github/workflows/test_and_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 94cf1e9..5f9ed4b 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -64,7 +64,7 @@ jobs: if: github.event_name != 'merge_group' with: token: ${{ secrets.CODECOV_TOKEN }} - fail_ci_if_error: true + fail_ci_if_error: false From 687ba2a279f0f1f5ef80b59258fe0caf6b8aa7fa Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 24 May 2024 14:16:47 +0100 Subject: [PATCH 21/29] Add some scientific Python repo recommendatiosn --- .github/workflows/test_and_deploy.yml | 4 ++++ pyproject.toml | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 5f9ed4b..2a8b731 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -12,6 +12,10 @@ on: workflow_dispatch: merge_group: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: test: name: ${{ matrix.platform }} py${{ matrix.python-version }} diff --git a/pyproject.toml b/pyproject.toml index bbec409..5a865b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools", "wheel", "setuptools_scm"] +requires = ["setuptools", "setuptools_scm"] build-backend = "setuptools.build_meta" [tool.setuptools_scm] @@ -16,7 +16,11 @@ filterwarnings = [ "ignore:Pickle, copy, and deepcopy support will be removed from itertools in Python 3.14.:DeprecationWarning" ] qt_api = "pyqt6" -addopts = "--mpl --mpl-baseline-relative" +addopts = ["--mpl", "--mpl-baseline-relative", "--strict-config", "--strict-markers", "-ra"] +minversion = "7" +testpaths = ["src/napari_matplotlib/tests"] +log_cli_level = "INFO" +xfail_strict = true [tool.black] line-length = 79 From 33a71d3231841b6452d677e2a94d0792e4ee3ffe Mon Sep 17 00:00:00 2001 From: David Stansby Date: Sat, 25 May 2024 09:29:58 +0100 Subject: [PATCH 22/29] Some more repo-review suggestions --- .pre-commit-config.yaml | 2 +- docs/conf.py | 1 + pyproject.toml | 12 ++++++++---- src/napari_matplotlib/histogram.py | 2 +- src/napari_matplotlib/tests/test_util.py | 2 +- src/napari_matplotlib/util.py | 9 +++++++-- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 40048ea..79342e2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/psf/black + - repo: https://github.com/psf/black-pre-commit-mirror rev: 24.4.2 hooks: - id: black diff --git a/docs/conf.py b/docs/conf.py index 2818f02..f153383 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -69,6 +69,7 @@ def napari_scraper(block, block_vars, gallery_conf): # type: ignore[no-untyped- for win, img_path in zip( reversed(napari._qt.qt_main_window._QtMainWindow._instances), imgpath_iter, + strict=False, ): img_paths.append(img_path) win._window.screenshot(img_path, canvas_only=False) diff --git a/pyproject.toml b/pyproject.toml index 5a865b0..05f7df6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,10 @@ line_length = 79 [tool.ruff] target-version = "py310" -select = ["I", "UP", "F", "E", "W", "D"] +fix = true + +[tool.ruff.lint] +select = ["B", "I", "UP", "F", "E", "W", "D"] ignore = [ "D100", # Missing docstring in public module "D104", # Missing docstring in public package @@ -41,14 +44,13 @@ ignore = [ "D401", # First line of docstring should be in imperative mood ] -fix = true -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "docs/*" = ["D"] "examples/*" = ["D"] "src/napari_matplotlib/tests/*" = ["D"] -[tool.ruff.pydocstyle] +[tool.ruff.lint.pydocstyle] convention = "numpy" [tool.mypy] @@ -59,6 +61,8 @@ disallow_subclassing_any = false # TODO: fix warn_return_any = false # TODO: fix ignore_missing_imports = true +enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] + [[tool.mypy.overrides]] module = [ "napari_matplotlib/tests/*", diff --git a/src/napari_matplotlib/histogram.py b/src/napari_matplotlib/histogram.py index a0b6e09..adbbae6 100644 --- a/src/napari_matplotlib/histogram.py +++ b/src/napari_matplotlib/histogram.py @@ -60,7 +60,7 @@ def on_update_layers(self) -> None: def _update_contrast_lims(self) -> None: for lim, line in zip( - self.layers[0].contrast_limits, self._contrast_lines + self.layers[0].contrast_limits, self._contrast_lines, strict=False ): line.set_xdata(lim) diff --git a/src/napari_matplotlib/tests/test_util.py b/src/napari_matplotlib/tests/test_util.py index 918e763..e966cc2 100644 --- a/src/napari_matplotlib/tests/test_util.py +++ b/src/napari_matplotlib/tests/test_util.py @@ -26,7 +26,7 @@ def test_interval(): assert 10 not in interval with pytest.raises(ValueError, match="must be an integer"): - "string" in interval # type: ignore + assert "string" in interval # type: ignore[operator] with pytest.raises(ValueError, match="must be <= upper_bound"): Interval(5, 3) diff --git a/src/napari_matplotlib/util.py b/src/napari_matplotlib/util.py index c54b60a..8d4150c 100644 --- a/src/napari_matplotlib/util.py +++ b/src/napari_matplotlib/util.py @@ -94,14 +94,18 @@ def _get_dimension(nodes: list[tinycss2.ast.Node], id_name: str) -> int | None: None if no IdentToken is found. """ cleaned_nodes = [node for node in nodes if node.type != "whitespace"] - for name, _, value, _ in zip(*(iter(cleaned_nodes),) * 4): + for name, _, value, _ in zip(*(iter(cleaned_nodes),) * 4, strict=False): if ( name.type == "ident" and value.type == "dimension" and name.value == id_name ): return value.int_value - warn(f"Unable to find DimensionToken for {id_name}", RuntimeWarning) + warn( + f"Unable to find DimensionToken for {id_name}", + RuntimeWarning, + stacklevel=1, + ) return None @@ -134,6 +138,7 @@ def from_napari_css_get_size_of( f"Unable to find {qt_element_name} or unable to find its size in " f"the current Napari stylesheet, falling back to {fallback}", RuntimeWarning, + stacklevel=1, ) return QSize(*fallback) From cf9aae9e5f2ed6acc9182a5b53110abf5f4a19ad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 17:37:35 +0000 Subject: [PATCH 23/29] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.2 → v0.4.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.2...v0.4.5) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 79342e2..ad71481 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.4.2' + rev: 'v0.4.5' hooks: - id: ruff From dea3e6d9e66187c8b3212453c076b7ec7492cbc2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 17:41:38 +0000 Subject: [PATCH 24/29] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.5 → v0.4.7](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.5...v0.4.7) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ad71481..aefedf4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.4.5' + rev: 'v0.4.7' hooks: - id: ruff From 34099bc0073e7e097773a328aaafae442a66889e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 17:44:38 +0000 Subject: [PATCH 25/29] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.7 → v0.4.8](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.7...v0.4.8) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aefedf4..c921bc0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.4.7' + rev: 'v0.4.8' hooks: - id: ruff From 5990ef63ad6580adadacc48ddc9548aa7c3c6d82 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 17:41:36 +0000 Subject: [PATCH 26/29] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.8 → v0.4.9](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.8...v0.4.9) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c921bc0..2fedfd8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.4.8' + rev: 'v0.4.9' hooks: - id: ruff From 2ad5adf83523e6ae8474c7aa9b0397c8f5ff20ab Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 17:41:57 +0000 Subject: [PATCH 27/29] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.9 → v0.4.10](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.9...v0.4.10) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2fedfd8..305eb83 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.4.9' + rev: 'v0.4.10' hooks: - id: ruff From c60ff0e3e2b829f55a8906f143189a72a1868ebd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 17:34:35 +0000 Subject: [PATCH 28/29] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-mypy: v1.10.0 → v1.10.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.10.0...v1.10.1) - [github.com/astral-sh/ruff-pre-commit: v0.4.10 → v0.5.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.10...v0.5.1) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 305eb83..ebae2d3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,14 +17,14 @@ repos: - id: napari-plugin-checks - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.10.0 + rev: v1.10.1 hooks: - id: mypy additional_dependencies: [numpy, matplotlib] - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.4.10' + rev: 'v0.5.1' hooks: - id: ruff From 3cb0fe7b7ddd391039b96e6fb6ff63cff3bbcfa9 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 12 Jul 2024 15:35:23 +0200 Subject: [PATCH 29/29] Pin max napari version --- docs/changelog.rst | 4 ++++ setup.cfg | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index ff2e60c..697e483 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,13 +1,17 @@ Changelog ========= + 2.0.2 ----- Dependencies ~~~~~~~~~~~~ napari-matplotlib now adheres to `SPEC 0 `_, and has: + - Dropped support for Python 3.9 - Added support for Python 3.12 - Added a minimum required numpy verison of 1.23 +- Pinned the maximum napari version to ``< 0.5``. + Version 3.0 of ``napari-matplotlib`` will introduce support for ``napari`` version 0.5. 2.0.1 ----- diff --git a/setup.cfg b/setup.cfg index 2b74504..073478a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,7 +28,7 @@ project_urls = packages = find: install_requires = matplotlib - napari + napari<0.5 numpy>=1.23 tinycss2 python_requires = >=3.10 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy