Skip to content

Commit de6b134

Browse files
committed
Update pre-commit hooks + mypy fixes
1 parent 4bf8a7e commit de6b134

File tree

8 files changed

+18
-13
lines changed

8 files changed

+18
-13
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ci:
66
default_stages: [pre-commit, pre-push]
77
repos:
88
- repo: https://github.com/astral-sh/ruff-pre-commit
9-
rev: v0.11.9
9+
rev: v0.11.13
1010
hooks:
1111
- id: ruff
1212
args: ["--fix", "--show-fixes"]
@@ -22,7 +22,7 @@ repos:
2222
- id: check-yaml
2323
- id: trailing-whitespace
2424
- repo: https://github.com/pre-commit/mirrors-mypy
25-
rev: v1.15.0
25+
rev: v1.16.0
2626
hooks:
2727
- id: mypy
2828
files: src|tests

src/zarr/core/buffer/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def ravel(self, order: Literal["K", "A", "C", "F"] = ...) -> Self: ...
9393

9494
def all(self) -> bool: ...
9595

96-
def __eq__(self, other: object) -> Self: # type: ignore[explicit-override, override]
96+
def __eq__(self, other: object) -> Self: # type: ignore[override]
9797
"""Element-wise equal
9898
9999
Notes

src/zarr/core/dtype/npy/bytes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,14 @@ def _check_native_dtype(
176176
Bool
177177
True if the dtype matches, False otherwise.
178178
"""
179-
return cls.dtype_cls is type(dtype) and dtype.fields is None # type: ignore[has-type]
179+
return cls.dtype_cls is type(dtype) and dtype.fields is None
180180

181181
@classmethod
182182
def from_native_dtype(cls, dtype: TBaseDType) -> Self:
183183
if cls._check_native_dtype(dtype):
184184
return cls(length=dtype.itemsize)
185185
raise DataTypeValidationError(
186-
f"Invalid data type: {dtype}. Expected an instance of {cls.dtype_cls}" # type: ignore[has-type]
186+
f"Invalid data type: {dtype}. Expected an instance of {cls.dtype_cls}"
187187
)
188188

189189
def to_native_dtype(self) -> np.dtypes.VoidDType[int]:

src/zarr/core/dtype/npy/structured.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def _check_native_dtype(cls, dtype: TBaseDType) -> TypeGuard[np.dtypes.VoidDType
5252
TypeGuard[np.dtypes.VoidDType]
5353
True if the dtype matches, False otherwise.
5454
"""
55-
return isinstance(dtype, cls.dtype_cls) and dtype.fields is not None # type: ignore[has-type]
55+
return isinstance(dtype, cls.dtype_cls) and dtype.fields is not None
5656

5757
@classmethod
5858
def from_native_dtype(cls, dtype: TBaseDType) -> Self:
@@ -68,7 +68,7 @@ def from_native_dtype(cls, dtype: TBaseDType) -> Self:
6868

6969
return cls(fields=tuple(fields))
7070
raise DataTypeValidationError(
71-
f"Invalid data type: {dtype}. Expected an instance of {cls.dtype_cls}" # type: ignore[has-type]
71+
f"Invalid data type: {dtype}. Expected an instance of {cls.dtype_cls}"
7272
)
7373

7474
def to_native_dtype(self) -> np.dtypes.VoidDType[int]:

src/zarr/core/dtype/npy/time.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def _from_json_v2(cls, data: DTypeJSON) -> Self:
230230
return cls.from_native_dtype(np.dtype(name))
231231
msg = (
232232
f"Invalid JSON representation of {cls.__name__}. Got {data!r}, expected a string "
233-
f"representation of an instance of {cls.dtype_cls}" # type: ignore[has-type]
233+
f"representation of an instance of {cls.dtype_cls}"
234234
)
235235
raise DataTypeValidationError(msg)
236236

@@ -318,7 +318,7 @@ def _from_json_v2(cls, data: DTypeJSON) -> Self:
318318
return cls.from_native_dtype(np.dtype(name))
319319
msg = (
320320
f"Invalid JSON representation of {cls.__name__}. Got {data!r}, expected a string "
321-
f"representation of an instance of {cls.dtype_cls}" # type: ignore[has-type]
321+
f"representation of an instance of {cls.dtype_cls}"
322322
)
323323
raise DataTypeValidationError(msg)
324324

src/zarr/storage/_memory.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ async def delete(self, key: str) -> None:
143143
except KeyError:
144144
logger.debug("Key %s does not exist.", key)
145145

146-
async def set_partial_values(self, key_start_values: Iterable[tuple[str, int, bytes]]) -> None:
146+
async def set_partial_values(
147+
self, key_start_values: Iterable[tuple[str, int, bytes | bytearray | memoryview[int]]]
148+
) -> None:
147149
# docstring inherited
148150
raise NotImplementedError
149151

src/zarr/storage/_zip.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,9 @@ async def set(self, key: str, value: Buffer) -> None:
222222
with self._lock:
223223
self._set(key, value)
224224

225-
async def set_partial_values(self, key_start_values: Iterable[tuple[str, int, bytes]]) -> None:
225+
async def set_partial_values(
226+
self, key_start_values: Iterable[tuple[str, int, bytes | bytearray | memoryview[int]]]
227+
) -> None:
226228
raise NotImplementedError
227229

228230
async def set_if_not_exists(self, key: str, value: Buffer) -> None:

tests/test_config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from zarr.core.codec_pipeline import BatchedCodecPipeline
2727
from zarr.core.config import BadConfigError, config
2828
from zarr.core.dtype import Int8, VariableLengthUTF8
29+
from zarr.core.dtype.wrapper import TBaseDType, TBaseScalar
2930
from zarr.core.indexing import SelectorTuple
3031
from zarr.registry import (
3132
fully_qualified_name,
@@ -329,9 +330,9 @@ async def test_default_codecs(dtype_category: str) -> None:
329330
"""
330331
Test that the default compressors are sensitive to the current setting of the config.
331332
"""
332-
zdtype: ZDType[Any, Any]
333+
zdtype: ZDType[TBaseDType, TBaseScalar]
333334
if dtype_category == "variable-length-string":
334-
zdtype = VariableLengthUTF8()
335+
zdtype = VariableLengthUTF8() # type: ignore[assignment]
335336
else:
336337
zdtype = Int8()
337338
expected_compressors = (GzipCodec(),)

0 commit comments

Comments
 (0)