From 09f4e91869d1459af58037c1b4c67a1ee1096da7 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Sun, 22 Oct 2023 12:50:13 +0100 Subject: [PATCH 1/2] Remove Python 3.8 support --- .github/workflows/test_and_deploy.yml | 2 +- .pre-commit-config.yaml | 2 +- pyproject.toml | 4 ++-- setup.cfg | 2 +- tox.ini | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 6e170d14..8665e1d2 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.8', '3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10', '3.11'] steps: - uses: actions/checkout@v3 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c1adb2e3..7bfb2d24 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,7 +20,7 @@ repos: rev: v1.6.0 hooks: - id: mypy - additional_dependencies: [numpy, matplotlib<3.8] + additional_dependencies: [numpy, matplotlib] - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. diff --git a/pyproject.toml b/pyproject.toml index 7c7dbbdd..705b4655 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ profile = "black" line_length = 79 [tool.ruff] -target-version = "py38" +target-version = "py39" select = ["I", "UP", "F", "E", "W", "D"] ignore = [ "D100", # Missing docstring in public module @@ -45,7 +45,7 @@ fix = true convention = "numpy" [tool.mypy] -python_version = "3.8" +python_version = "3.9" # Block below are checks that form part of mypy 'strict' mode warn_unused_configs = true warn_redundant_casts = true diff --git a/setup.cfg b/setup.cfg index 70ad93a2..b962611d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,7 +31,7 @@ install_requires = napari numpy tinycss2 -python_requires = >=3.8 +python_requires = >=3.9 include_package_data = True package_dir = =src diff --git a/tox.ini b/tox.ini index 683992f5..0125d792 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,12 @@ [tox] -envlist = py{38,39,310,311} +envlist = py{39,310,311} isolated_build = true [gh-actions] python = - 3.8: py38 3.9: py39 3.10: py310 + 3.11: py311 [testenv] extras = testing From d768a924145e482664a49bee0000740c0e07cc8f Mon Sep 17 00:00:00 2001 From: David Stansby Date: Sun, 22 Oct 2023 13:00:40 +0100 Subject: [PATCH 2/2] Typing upgrades --- src/napari_matplotlib/base.py | 6 +++--- src/napari_matplotlib/histogram.py | 6 +++--- src/napari_matplotlib/scatter.py | 12 ++++++------ src/napari_matplotlib/slice.py | 6 +++--- .../tests/scatter/test_scatter_features.py | 4 ++-- src/napari_matplotlib/tests/test_layer_changes.py | 6 +++--- src/napari_matplotlib/util.py | 8 ++++---- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/napari_matplotlib/base.py b/src/napari_matplotlib/base.py index 792b5aff..21b4a044 100644 --- a/src/napari_matplotlib/base.py +++ b/src/napari_matplotlib/base.py @@ -1,6 +1,6 @@ import os from pathlib import Path -from typing import List, Optional, Tuple +from typing import Optional import matplotlib import matplotlib.style as mplstyle @@ -184,7 +184,7 @@ class NapariMPLWidget(BaseNapariMPLWidget): #: Number of layers taken as input n_layers_input = Interval(None, None) #: Type of layer taken as input - input_layer_types: Tuple[napari.layers.Layer, ...] = (napari.layers.Layer,) + input_layer_types: tuple[napari.layers.Layer, ...] = (napari.layers.Layer,) def __init__( self, @@ -193,7 +193,7 @@ def __init__( ): super().__init__(napari_viewer=napari_viewer, parent=parent) self._setup_callbacks() - self.layers: List[napari.layers.Layer] = [] + self.layers: list[napari.layers.Layer] = [] helper_text = self.n_layers_input._helper_text if helper_text is not None: diff --git a/src/napari_matplotlib/histogram.py b/src/napari_matplotlib/histogram.py index 66aa7acc..c853988a 100644 --- a/src/napari_matplotlib/histogram.py +++ b/src/napari_matplotlib/histogram.py @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Tuple +from typing import Any, Optional import napari import numpy as np @@ -107,7 +107,7 @@ def _set_axis_keys(self, x_axis_key: str) -> None: self._x_axis_key = x_axis_key self._draw() - def _get_valid_axis_keys(self) -> List[str]: + def _get_valid_axis_keys(self) -> list[str]: """ Get the valid axis keys from the layer FeatureTable. @@ -122,7 +122,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[Optional[npt.NDArray[Any]], str]: """Get the plot data. Returns diff --git a/src/napari_matplotlib/scatter.py b/src/napari_matplotlib/scatter.py index a4148bd2..67d6896c 100644 --- a/src/napari_matplotlib/scatter.py +++ b/src/napari_matplotlib/scatter.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional, Tuple, Union +from typing import Any, Optional, Union import napari import numpy.typing as npt @@ -40,7 +40,7 @@ def draw(self) -> None: self.axes.set_xlabel(x_axis_name) self.axes.set_ylabel(y_axis_name) - def _get_data(self) -> Tuple[npt.NDArray[Any], npt.NDArray[Any], str, str]: + def _get_data(self) -> tuple[npt.NDArray[Any], npt.NDArray[Any], str, str]: """ Get the plot data. @@ -67,7 +67,7 @@ class ScatterWidget(ScatterBaseWidget): n_layers_input = Interval(2, 2) input_layer_types = (napari.layers.Image,) - def _get_data(self) -> Tuple[npt.NDArray[Any], npt.NDArray[Any], str, str]: + def _get_data(self) -> tuple[npt.NDArray[Any], npt.NDArray[Any], str, str]: """ Get the plot data. @@ -106,7 +106,7 @@ def __init__( self.layout().addLayout(QVBoxLayout()) - self._selectors: Dict[str, QComboBox] = {} + self._selectors: dict[str, QComboBox] = {} for dim in ["x", "y"]: self._selectors[dim] = QComboBox() # Re-draw when combo boxes are updated @@ -147,7 +147,7 @@ def y_axis_key(self, key: str) -> None: self._selectors["y"].setCurrentText(key) self._draw() - def _get_valid_axis_keys(self) -> List[str]: + def _get_valid_axis_keys(self) -> list[str]: """ Get the valid axis keys from the layer FeatureTable. @@ -186,7 +186,7 @@ def draw(self) -> None: if self._ready_to_scatter(): super().draw() - def _get_data(self) -> Tuple[npt.NDArray[Any], npt.NDArray[Any], str, str]: + def _get_data(self) -> tuple[npt.NDArray[Any], npt.NDArray[Any], str, str]: """ Get the plot data from the ``features`` attribute of the first selected layer. diff --git a/src/napari_matplotlib/slice.py b/src/napari_matplotlib/slice.py index 393f2e45..9459fa97 100644 --- a/src/napari_matplotlib/slice.py +++ b/src/napari_matplotlib/slice.py @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Tuple +from typing import Any, Optional import matplotlib.ticker as mticker import napari @@ -99,7 +99,7 @@ def current_dim_index(self) -> int: return self._dim_names.index(self.current_dim_name) @property - def _dim_names(self) -> List[str]: + def _dim_names(self) -> list[str]: """ List of dimension names. This is a property as it varies depending on the dimensionality of the currently selected data. @@ -111,7 +111,7 @@ def _dim_names(self) -> List[str]: else: raise RuntimeError("Don't know how to handle ndim != 2 or 3") - def _get_xy(self) -> Tuple[npt.NDArray[Any], npt.NDArray[Any]]: + def _get_xy(self) -> tuple[npt.NDArray[Any], npt.NDArray[Any]]: """ Get data for plotting. """ diff --git a/src/napari_matplotlib/tests/scatter/test_scatter_features.py b/src/napari_matplotlib/tests/scatter/test_scatter_features.py index b5a396fd..3ede1e28 100644 --- a/src/napari_matplotlib/tests/scatter/test_scatter_features.py +++ b/src/napari_matplotlib/tests/scatter/test_scatter_features.py @@ -1,5 +1,5 @@ from copy import deepcopy -from typing import Any, Dict, Tuple +from typing import Any import numpy as np import numpy.typing as npt @@ -34,7 +34,7 @@ def test_features_scatter_widget_2D( def make_labels_layer_with_features() -> ( - Tuple[npt.NDArray[np.uint16], Dict[str, Any]] + tuple[npt.NDArray[np.uint16], dict[str, Any]] ): label_image: npt.NDArray[np.uint16] = np.zeros((100, 100), dtype=np.uint16) for label_value, start_index in enumerate([10, 30, 50], start=1): diff --git a/src/napari_matplotlib/tests/test_layer_changes.py b/src/napari_matplotlib/tests/test_layer_changes.py index bdd6c600..15958c07 100644 --- a/src/napari_matplotlib/tests/test_layer_changes.py +++ b/src/napari_matplotlib/tests/test_layer_changes.py @@ -1,5 +1,5 @@ from copy import deepcopy -from typing import Any, Dict, Tuple, Type +from typing import Any import numpy as np import numpy.typing as npt @@ -61,8 +61,8 @@ def test_change_features_layer( def assert_features_plot_changes( viewer: Viewer, - widget_cls: Type[NapariMPLWidget], - data: Tuple[npt.NDArray[np.generic], Dict[str, Any]], + widget_cls: type[NapariMPLWidget], + data: tuple[npt.NDArray[np.generic], dict[str, Any]], ) -> None: """ When the selected layer is changed, make sure the plot generated diff --git a/src/napari_matplotlib/util.py b/src/napari_matplotlib/util.py index 2aa15ddd..7d72c9e2 100644 --- a/src/napari_matplotlib/util.py +++ b/src/napari_matplotlib/util.py @@ -1,4 +1,4 @@ -from typing import List, Optional, Tuple, Union +from typing import Optional, Union from warnings import warn import napari.qt @@ -76,7 +76,7 @@ def _helper_text(self) -> Optional[str]: return helper_text -def _has_id(nodes: List[tinycss2.ast.Node], id_name: str) -> bool: +def _has_id(nodes: list[tinycss2.ast.Node], id_name: str) -> bool: """ Is `id_name` in IdentTokens in the list of CSS `nodes`? """ @@ -86,7 +86,7 @@ def _has_id(nodes: List[tinycss2.ast.Node], id_name: str) -> bool: def _get_dimension( - nodes: List[tinycss2.ast.Node], id_name: str + nodes: list[tinycss2.ast.Node], id_name: str ) -> Union[int, None]: """ Get the value of the DimensionToken for the IdentToken `id_name`. @@ -108,7 +108,7 @@ def _get_dimension( def from_napari_css_get_size_of( - qt_element_name: str, fallback: Tuple[int, int] + qt_element_name: str, fallback: tuple[int, int] ) -> QSize: """ Get the size of `qt_element_name` from napari's current stylesheet. 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