Skip to content

Commit 23cfc35

Browse files
committed
Update pre-commit hooks + mypy fixes
1 parent 2911be8 commit 23cfc35

File tree

8 files changed

+17
-13
lines changed

8 files changed

+17
-13
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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.1
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
)
4848

4949
if TYPE_CHECKING:
50-
from zarr.core.dtype.wrapper import ZDType
50+
from zarr.core.dtype.wrapper import TBaseDType, TBaseScalar, ZDType
5151

5252

5353
def test_config_defaults_set() -> None:
@@ -329,9 +329,9 @@ async def test_default_codecs(dtype_category: str) -> None:
329329
"""
330330
Test that the default compressors are sensitive to the current setting of the config.
331331
"""
332-
zdtype: ZDType[Any, Any]
332+
zdtype: ZDType[TBaseDType, TBaseScalar]
333333
if dtype_category == "variable-length-string":
334-
zdtype = VariableLengthUTF8()
334+
zdtype = VariableLengthUTF8() # type: ignore[assignment]
335335
else:
336336
zdtype = Int8()
337337
expected_compressors = (GzipCodec(),)

0 commit comments

Comments
 (0)