diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fd50366a1c..f016000984 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: check-yaml - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.15.0 + rev: v1.16.1 hooks: - id: mypy files: src|tests diff --git a/src/zarr/core/buffer/core.py b/src/zarr/core/buffer/core.py index 0e24c5b326..2f7ced4a74 100644 --- a/src/zarr/core/buffer/core.py +++ b/src/zarr/core/buffer/core.py @@ -93,7 +93,7 @@ def ravel(self, order: Literal["K", "A", "C", "F"] = ...) -> Self: ... def all(self) -> bool: ... - def __eq__(self, other: object) -> Self: # type: ignore[explicit-override, override] + def __eq__(self, other: object) -> Self: # type: ignore[override] """Element-wise equal Notes diff --git a/src/zarr/core/dtype/npy/bytes.py b/src/zarr/core/dtype/npy/bytes.py index e363c75053..25f44a9658 100644 --- a/src/zarr/core/dtype/npy/bytes.py +++ b/src/zarr/core/dtype/npy/bytes.py @@ -176,14 +176,14 @@ def _check_native_dtype( Bool True if the dtype matches, False otherwise. """ - return cls.dtype_cls is type(dtype) and dtype.fields is None # type: ignore[has-type] + return cls.dtype_cls is type(dtype) and dtype.fields is None @classmethod def from_native_dtype(cls, dtype: TBaseDType) -> Self: if cls._check_native_dtype(dtype): return cls(length=dtype.itemsize) raise DataTypeValidationError( - f"Invalid data type: {dtype}. Expected an instance of {cls.dtype_cls}" # type: ignore[has-type] + f"Invalid data type: {dtype}. Expected an instance of {cls.dtype_cls}" ) def to_native_dtype(self) -> np.dtypes.VoidDType[int]: diff --git a/src/zarr/core/dtype/npy/structured.py b/src/zarr/core/dtype/npy/structured.py index 07e3000826..bfdbf7bd95 100644 --- a/src/zarr/core/dtype/npy/structured.py +++ b/src/zarr/core/dtype/npy/structured.py @@ -52,7 +52,7 @@ def _check_native_dtype(cls, dtype: TBaseDType) -> TypeGuard[np.dtypes.VoidDType TypeGuard[np.dtypes.VoidDType] True if the dtype matches, False otherwise. """ - return isinstance(dtype, cls.dtype_cls) and dtype.fields is not None # type: ignore[has-type] + return isinstance(dtype, cls.dtype_cls) and dtype.fields is not None @classmethod def from_native_dtype(cls, dtype: TBaseDType) -> Self: @@ -68,7 +68,7 @@ def from_native_dtype(cls, dtype: TBaseDType) -> Self: return cls(fields=tuple(fields)) raise DataTypeValidationError( - f"Invalid data type: {dtype}. Expected an instance of {cls.dtype_cls}" # type: ignore[has-type] + f"Invalid data type: {dtype}. Expected an instance of {cls.dtype_cls}" ) def to_native_dtype(self) -> np.dtypes.VoidDType[int]: diff --git a/src/zarr/core/dtype/npy/time.py b/src/zarr/core/dtype/npy/time.py index 1f9080475c..2fd140ef91 100644 --- a/src/zarr/core/dtype/npy/time.py +++ b/src/zarr/core/dtype/npy/time.py @@ -230,7 +230,7 @@ def _from_json_v2(cls, data: DTypeJSON) -> Self: return cls.from_native_dtype(np.dtype(name)) msg = ( f"Invalid JSON representation of {cls.__name__}. Got {data!r}, expected a string " - f"representation of an instance of {cls.dtype_cls}" # type: ignore[has-type] + f"representation of an instance of {cls.dtype_cls}" ) raise DataTypeValidationError(msg) @@ -318,7 +318,7 @@ def _from_json_v2(cls, data: DTypeJSON) -> Self: return cls.from_native_dtype(np.dtype(name)) msg = ( f"Invalid JSON representation of {cls.__name__}. Got {data!r}, expected a string " - f"representation of an instance of {cls.dtype_cls}" # type: ignore[has-type] + f"representation of an instance of {cls.dtype_cls}" ) raise DataTypeValidationError(msg) diff --git a/src/zarr/storage/_memory.py b/src/zarr/storage/_memory.py index 0dc6f13236..5c12563136 100644 --- a/src/zarr/storage/_memory.py +++ b/src/zarr/storage/_memory.py @@ -143,7 +143,9 @@ async def delete(self, key: str) -> None: except KeyError: logger.debug("Key %s does not exist.", key) - async def set_partial_values(self, key_start_values: Iterable[tuple[str, int, bytes]]) -> None: + async def set_partial_values( + self, key_start_values: Iterable[tuple[str, int, bytes | bytearray | memoryview[int]]] + ) -> None: # docstring inherited raise NotImplementedError diff --git a/src/zarr/storage/_zip.py b/src/zarr/storage/_zip.py index 5d147deded..e52f160860 100644 --- a/src/zarr/storage/_zip.py +++ b/src/zarr/storage/_zip.py @@ -222,7 +222,9 @@ async def set(self, key: str, value: Buffer) -> None: with self._lock: self._set(key, value) - async def set_partial_values(self, key_start_values: Iterable[tuple[str, int, bytes]]) -> None: + async def set_partial_values( + self, key_start_values: Iterable[tuple[str, int, bytes | bytearray | memoryview[int]]] + ) -> None: raise NotImplementedError async def set_if_not_exists(self, key: str, value: Buffer) -> None: diff --git a/tests/test_config.py b/tests/test_config.py index ed778a02ae..e267601272 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -47,7 +47,7 @@ ) if TYPE_CHECKING: - from zarr.core.dtype.wrapper import ZDType + from zarr.core.dtype.wrapper import TBaseDType, TBaseScalar, ZDType def test_config_defaults_set() -> None: @@ -329,9 +329,9 @@ async def test_default_codecs(dtype_category: str) -> None: """ Test that the default compressors are sensitive to the current setting of the config. """ - zdtype: ZDType[Any, Any] + zdtype: ZDType[TBaseDType, TBaseScalar] if dtype_category == "variable-length-string": - zdtype = VariableLengthUTF8() + zdtype = VariableLengthUTF8() # type: ignore[assignment] else: zdtype = Int8() expected_compressors = (GzipCodec(),)