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)