From 752d1de1c9da198c634b29665b366c25b1291eeb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 4 May 2026 19:09:18 +0000 Subject: [PATCH 1/2] chore: update pre-commit hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.15.4 → v0.15.12](https://github.com/astral-sh/ruff-pre-commit/compare/v0.15.4...v0.15.12) - [github.com/codespell-project/codespell: v2.4.1 → v2.4.2](https://github.com/codespell-project/codespell/compare/v2.4.1...v2.4.2) - [github.com/pre-commit/mirrors-mypy: v1.19.1 → v1.20.2](https://github.com/pre-commit/mirrors-mypy/compare/v1.19.1...v1.20.2) - [github.com/scientific-python/cookie: 2026.03.02 → 2026.04.04](https://github.com/scientific-python/cookie/compare/2026.03.02...2026.04.04) - [github.com/zizmorcore/zizmor-pre-commit: v1.23.1 → v1.24.1](https://github.com/zizmorcore/zizmor-pre-commit/compare/v1.23.1...v1.24.1) --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6e6c21b581..c9c0e61668 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,13 +11,13 @@ default_language_version: repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.4 + rev: v0.15.12 hooks: - id: ruff-check args: ["--fix", "--show-fixes"] - id: ruff-format - repo: https://github.com/codespell-project/codespell - rev: v2.4.1 + rev: v2.4.2 hooks: - id: codespell args: ["-L", "fo,ihs,kake,te", "-S", "fixture"] @@ -28,7 +28,7 @@ repos: exclude: mkdocs.yml - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.19.1 + rev: v1.20.2 hooks: - id: mypy files: ^(src|tests)/ @@ -47,7 +47,7 @@ repos: - hypothesis - s3fs - repo: https://github.com/scientific-python/cookie - rev: 2026.03.02 + rev: 2026.04.04 hooks: - id: sp-repo-review - repo: https://github.com/numpy/numpydoc @@ -64,7 +64,7 @@ repos: types: [python] files: ^(src|tests)/ - repo: https://github.com/zizmorcore/zizmor-pre-commit - rev: v1.23.1 + rev: v1.24.1 hooks: - id: zizmor - repo: https://github.com/twisted/towncrier From cf67186272582a889440195bc64699e0be9e61be Mon Sep 17 00:00:00 2001 From: Davis Vann Bennett Date: Wed, 6 May 2026 14:17:22 -0400 Subject: [PATCH 2/2] chore: fix pre-commit failures --- src/zarr/core/array.py | 2 +- src/zarr/core/dtype/npy/structured.py | 5 +++-- src/zarr/storage/_logging.py | 2 +- src/zarr/storage/_wrapper.py | 2 +- tests/test_api.py | 8 ++++---- tests/test_array.py | 2 +- tests/test_codecs/test_numcodecs.py | 10 +++++----- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/zarr/core/array.py b/src/zarr/core/array.py index 8183a63beb..37f65fce32 100644 --- a/src/zarr/core/array.py +++ b/src/zarr/core/array.py @@ -4816,7 +4816,7 @@ def _parse_keep_array_attr( if serializer == "keep": serializer = "auto" # After resolving "keep" above, chunks is never "keep" at this point. - chunks_out: ChunksLike | Literal["auto"] = chunks # type: ignore[assignment] + chunks_out: ChunksLike | Literal["auto"] = chunks return ( chunks_out, shards, diff --git a/src/zarr/core/dtype/npy/structured.py b/src/zarr/core/dtype/npy/structured.py index d111924e6c..c5ff5b68a3 100644 --- a/src/zarr/core/dtype/npy/structured.py +++ b/src/zarr/core/dtype/npy/structured.py @@ -278,15 +278,16 @@ def _from_json_v2(cls, data: DTypeJSON) -> Self: # structured dtypes are constructed directly from a list of lists # note that we do not handle the object codec here! this will prevent structured # dtypes from containing object dtypes. + name = data["name"] return cls( - fields=tuple( # type: ignore[misc] + fields=tuple( # type: ignore[str-unpack] ( # type: ignore[misc] f_name, get_data_type_from_json( {"name": f_dtype, "object_codec_id": None}, zarr_format=2 ), ) - for f_name, f_dtype in data["name"] + for f_name, f_dtype in name ) ) msg = f"Invalid JSON representation of {cls.__name__}. Got {data!r}, expected a JSON array of arrays" diff --git a/src/zarr/storage/_logging.py b/src/zarr/storage/_logging.py index a4c376c332..5de300c144 100644 --- a/src/zarr/storage/_logging.py +++ b/src/zarr/storage/_logging.py @@ -161,7 +161,7 @@ def __repr__(self) -> str: def __eq__(self, other: object) -> bool: with self.log(other): - return type(self) is type(other) and self._store.__eq__(other._store) # type: ignore[attr-defined] + return type(self) is type(other) and self._store.__eq__(other._store) async def get( self, diff --git a/src/zarr/storage/_wrapper.py b/src/zarr/storage/_wrapper.py index 50fe5c0e59..d8ecfa6d45 100644 --- a/src/zarr/storage/_wrapper.py +++ b/src/zarr/storage/_wrapper.py @@ -83,7 +83,7 @@ def _check_writable(self) -> None: return self._store._check_writable() def __eq__(self, value: object) -> bool: - return type(self) is type(value) and self._store.__eq__(value._store) # type: ignore[attr-defined] + return type(self) is type(value) and self._store.__eq__(value._store) def __str__(self) -> str: return f"wrapping-{self._store}" diff --git a/tests/test_api.py b/tests/test_api.py index d8c4d20f4a..788519969d 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -137,7 +137,7 @@ async def test_array_like_creation( kwargs["fill_value"] = out_fill expect_fill = out_fill elif func is zarr.api.asynchronous.open_like: # type: ignore[comparison-overlap] - if out_fill == "keep": + if out_fill == "keep": # type: ignore[unreachable] expect_fill = ref_fill else: kwargs["fill_value"] = out_fill @@ -161,7 +161,7 @@ async def test_array_like_creation( else: expect_dtype = ref_arr.dtype # type: ignore[assignment] - new_arr = await func(ref_arr, path="foo", zarr_format=zarr_format, **kwargs) # type: ignore[call-arg] + new_arr = await func(ref_arr, path="foo", zarr_format=zarr_format, **kwargs) assert new_arr.shape == expect_shape assert new_arr.chunks == expect_chunks assert new_arr.dtype == expect_dtype @@ -187,7 +187,7 @@ def test_create_array(store: Store, zarr_format: ZarrFormat) -> None: array_w[:] = data_val assert array_w.shape == shape assert array_w.attrs == attrs - assert np.array_equal(array_w[:], np.zeros(shape, dtype=array_w.dtype) + data_val) + assert np.array_equal(array_w[:], np.zeros(shape, dtype=array_w.dtype) + data_val) # type: ignore[unreachable] @pytest.mark.parametrize("write_empty_chunks", [True, False]) @@ -326,7 +326,7 @@ async def test_create_group(store: Store, zarr_format: ZarrFormat) -> None: node = create_group(store, path=path, attributes=attrs, zarr_format=zarr_format) assert isinstance(node, Group) assert node.attrs == attrs - assert node.metadata.zarr_format == zarr_format + assert node.metadata.zarr_format == zarr_format # type: ignore[unreachable] async def test_open_group(memory_store: MemoryStore) -> None: diff --git a/tests/test_array.py b/tests/test_array.py index 132c4c26c3..e5e875a31a 100644 --- a/tests/test_array.py +++ b/tests/test_array.py @@ -1770,7 +1770,7 @@ async def test_from_array( assert result.fill_value == new_fill_value assert result.dtype == src_dtype assert result.attrs == new_attributes - assert result.chunks == new_chunks + assert result.chunks == new_chunks # type: ignore[unreachable] @pytest.mark.parametrize("store", ["local"], indirect=True) diff --git a/tests/test_codecs/test_numcodecs.py b/tests/test_codecs/test_numcodecs.py index eec0ecacae..7d5a0c29c4 100644 --- a/tests/test_codecs/test_numcodecs.py +++ b/tests/test_codecs/test_numcodecs.py @@ -85,7 +85,7 @@ def test_is_numcodec_cls() -> None: @pytest.mark.parametrize("codec_cls", ALL_CODECS) def test_get_codec_class(codec_cls: type[_numcodecs._NumcodecsCodec]) -> None: - assert get_codec_class(codec_cls.codec_name) == codec_cls # type: ignore[comparison-overlap] + assert get_codec_class(codec_cls.codec_name) == codec_cls # type: ignore[comparison-overlap,misc] @pytest.mark.parametrize("codec_class", ALL_CODECS) @@ -240,7 +240,7 @@ def test_generic_checksum(codec_class: type[_numcodecs._NumcodecsBytesBytesCodec try: codec_class()._codec # noqa: B018 except UnknownCodecError as e: # pragma: no cover - pytest.skip(f"{codec_class.codec_name} is not available in numcodecs: {e}") + pytest.skip(f"{codec_class.codec_name} is not available in numcodecs: {e}") # type: ignore[misc] data = np.linspace(0, 10, 256, dtype="float32").reshape((16, 16)) @@ -265,11 +265,11 @@ def test_generic_bytes_codec(codec_class: type[_numcodecs._NumcodecsArrayBytesCo codec_class()._codec # noqa: B018 except ValueError as e: # pragma: no cover if "codec not available" in str(e): - pytest.xfail(f"{codec_class.codec_name} is not available: {e}") + pytest.xfail(f"{codec_class.codec_name} is not available: {e}") # type: ignore[misc] else: raise except ImportError as e: # pragma: no cover - pytest.xfail(f"{codec_class.codec_name} is not available: {e}") + pytest.xfail(f"{codec_class.codec_name} is not available: {e}") # type: ignore[misc] data = np.arange(0, 256, dtype="float32").reshape((16, 16)) @@ -347,7 +347,7 @@ def test_codecs_pickleable(codec_cls: type[_numcodecs._NumcodecsCodec]) -> None: try: codec = codec_cls() except UnknownCodecError as e: # pragma: no cover - pytest.skip(f"{codec_cls.codec_name} is not available in numcodecs: {e}") + pytest.skip(f"{codec_cls.codec_name} is not available in numcodecs: {e}") # type: ignore[misc] expected = codec