From f9af6e8fead6b14a33b47227913a943700f84963 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Mon, 14 Apr 2025 12:00:10 -0500 Subject: [PATCH 1/2] pre-commit: add codespell Signed-off-by: Benjamin Gilbert --- .pre-commit-config.yaml | 8 ++++++++ pyproject.toml | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9affb18..457d20b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -67,6 +67,14 @@ repos: name: Validate reStructuredText syntax additional_dependencies: [sphinx, toml] + - repo: https://github.com/codespell-project/codespell + rev: v2.4.1 + hooks: + - id: codespell + name: Check spelling with codespell + additional_dependencies: + - tomli # Python < 3.11 + - repo: meta hooks: - id: check-hooks-apply diff --git a/pyproject.toml b/pyproject.toml index 6394f6f..bb8eaea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,6 +51,12 @@ openslide = ["py.typed", "*.pyi"] skip-string-normalization = true target-version = ["py38", "py39", "py310", "py311", "py312", "py313"] +# Ref: https://github.com/codespell-project/codespell#using-a-config-file +[tool.codespell] +check-hidden = true +# ignore-regex = "" +# ignore-words-list = "" + # https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8 # also ignore: # - E741 ambiguous variable name From 3e48604c2c3b0721ac29b6e6926b319dd26f28a7 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Mon, 14 Apr 2025 13:17:31 -0500 Subject: [PATCH 2/2] pre-commit: update versions _Func.__call__() correctly does not have a **kwargs argument. Signed-off-by: Benjamin Gilbert --- .pre-commit-config.yaml | 10 +++++----- openslide/deepzoom.py | 4 ++-- openslide/lowlevel.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 457d20b..633bcbf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,20 +16,20 @@ repos: - id: trailing-whitespace - repo: https://github.com/asottile/pyupgrade - rev: v3.19.0 + rev: v3.19.1 hooks: - id: pyupgrade name: Modernize python code args: ["--py38-plus"] - repo: https://github.com/PyCQA/isort - rev: 5.13.2 + rev: 6.0.1 hooks: - id: isort name: Reorder python imports with isort - repo: https://github.com/psf/black - rev: 24.10.0 + rev: 25.1.0 hooks: - id: black name: Format python code with black @@ -47,14 +47,14 @@ repos: additional_dependencies: [flake8-bugbear, Flake8-pyproject] - repo: https://github.com/PyCQA/flake8 - rev: 7.1.1 + rev: 7.2.0 hooks: - id: flake8 name: Lint python code with flake8 additional_dependencies: [flake8-bugbear, Flake8-pyproject] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.13.0 + rev: v1.15.0 hooks: - id: mypy name: Check Python types diff --git a/openslide/deepzoom.py b/openslide/deepzoom.py index 9d0b3ab..e712b0e 100644 --- a/openslide/deepzoom.py +++ b/openslide/deepzoom.py @@ -263,10 +263,10 @@ def _z_from_t(self, t: int) -> int: @staticmethod def _pairs_from_n_tuples( - tuples: tuple[tuple[int, ...], ...] + tuples: tuple[tuple[int, ...], ...], ) -> tuple[tuple[int, int], ...]: def all_pairs( - tuples: tuple[tuple[int, ...], ...] + tuples: tuple[tuple[int, ...], ...], ) -> TypeGuard[tuple[tuple[int, int], ...]]: return all(len(t) == 2 for t in tuples) diff --git a/openslide/lowlevel.py b/openslide/lowlevel.py index 11ccc57..9aab42b 100644 --- a/openslide/lowlevel.py +++ b/openslide/lowlevel.py @@ -322,7 +322,7 @@ def __call__(self, *_args: Any) -> Any: class _Func(Protocol[_P, _T]): available: bool - def __call__(self, *args: _P.args) -> _T: ... + def __call__(self, *args: _P.args) -> _T: ... # type: ignore[valid-type] class _CTypesFunc(_Func[_P, _T]): restype: type | None @@ -358,7 +358,7 @@ def _func( def _wraps_funcs( - wrapped: list[_Func[..., Any]] + wrapped: list[_Func[..., Any]], ) -> Callable[[Callable[_P, _T]], _Func[_P, _T]]: def decorator(fn: Callable[_P, _T]) -> _Func[_P, _T]: if TYPE_CHECKING: