Skip to content

Commit 098faf6

Browse files
Fix mypy 1.16 errors
error: Unused "type: ignore" comment [unused-ignore]
1 parent 286bef8 commit 098faf6

File tree

25 files changed

+57
-57
lines changed

25 files changed

+57
-57
lines changed

src/zarr/api/asynchronous.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def _like_args(a: ArrayLike, kwargs: dict[str, Any]) -> dict[str, Any]:
140140
else:
141141
# TODO: Remove type: ignore statement when type inference improves.
142142
# mypy cannot correctly infer the type of a.metadata here for some reason.
143-
new["codecs"] = a.metadata.codecs # type: ignore[unreachable]
143+
new["codecs"] = a.metadata.codecs
144144

145145
else:
146146
# TODO: set default values compressor/codecs

src/zarr/codecs/bytes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ async def _encode_single(
107107
):
108108
# type-ignore is a numpy bug
109109
# see https://github.com/numpy/numpy/issues/26473
110-
new_dtype = chunk_array.dtype.newbyteorder(self.endian.name) # type: ignore[arg-type]
110+
new_dtype = chunk_array.dtype.newbyteorder(self.endian.name)
111111
chunk_array = chunk_array.astype(new_dtype)
112112

113113
nd_array = chunk_array.as_ndarray_like()

src/zarr/core/array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ def _create_metadata_v2(
782782
if dimension_separator is None:
783783
dimension_separator = "."
784784
if fill_value is None:
785-
fill_value = dtype.default_scalar() # type: ignore[assignment]
785+
fill_value = dtype.default_scalar()
786786
return ArrayV2Metadata(
787787
shape=shape,
788788
dtype=dtype,

src/zarr/core/buffer/core.py

Lines changed: 2 additions & 2 deletions
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:
9797
"""Element-wise equal
9898
9999
Notes
@@ -266,7 +266,7 @@ def as_buffer_like(self) -> BytesLike:
266266
-------
267267
An object that implements the Python buffer protocol
268268
"""
269-
return memoryview(self.as_numpy_array()) # type: ignore[arg-type]
269+
return memoryview(self.as_numpy_array())
270270

271271
def to_bytes(self) -> bytes:
272272
"""Returns the buffer as `bytes` (host memory).

src/zarr/core/dtype/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114

115115
for dtype in ANY_DTYPE:
116116
# mypy does not know that all the elements of ANY_DTYPE are subclasses of ZDType
117-
data_type_registry.register(dtype._zarr_v3_name, dtype) # type: ignore[arg-type]
117+
data_type_registry.register(dtype._zarr_v3_name, dtype)
118118

119119

120120
# TODO: find a better name for this function
@@ -159,4 +159,4 @@ def parse_data_type(
159159
return get_data_type_from_json(dtype_spec, zarr_format=3)
160160
# otherwise, we have either a numpy dtype string, or a zarr v3 dtype string, and in either case
161161
# we can create a numpy dtype from it, and do the dtype inference from that
162-
return get_data_type_from_native_dtype(dtype_spec) # type: ignore[arg-type]
162+
return get_data_type_from_native_dtype(dtype_spec)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class RawBytes(ZDType[np.dtypes.VoidDType[int], np.void], HasLength, HasItemSize
152152
# np.dtypes.VoidDType is specified in an odd way in numpy
153153
# it cannot be used to create instances of the dtype
154154
# so we have to tell mypy to ignore this here
155-
dtype_cls = np.dtypes.VoidDType # type: ignore[assignment]
155+
dtype_cls = np.dtypes.VoidDType
156156
_zarr_v3_name: ClassVar[Literal["raw_bytes"]] = "raw_bytes"
157157

158158
@classmethod
@@ -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/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def get_endianness_from_numpy_dtype(dtype: np.dtype[np.generic]) -> EndiannessSt
138138
"""
139139
endianness = dtype.byteorder
140140
if dtype.byteorder in NUMPY_ENDIANNESS_STR:
141-
return endianness_from_numpy_str(endianness) # type: ignore [arg-type]
141+
return endianness_from_numpy_str(endianness)
142142
raise ValueError(f"The dtype {dtype} has an unsupported endianness: {endianness}")
143143

144144

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def from_native_dtype(cls, dtype: TBaseDType) -> Self:
5454

5555
def to_native_dtype(self) -> TComplexDType_co:
5656
byte_order = endianness_to_numpy_str(self.endianness)
57-
return self.dtype_cls().newbyteorder(byte_order) # type: ignore[return-value]
57+
return self.dtype_cls().newbyteorder(byte_order)
5858

5959
@classmethod
6060
def _check_json_v2(cls, data: DTypeJSON) -> TypeGuard[DTypeConfig_V2[str, None]]:
@@ -118,7 +118,7 @@ def _check_scalar(self, data: object) -> TypeGuard[ComplexLike]:
118118
return isinstance(data, ComplexLike)
119119

120120
def _cast_scalar_unchecked(self, data: ComplexLike) -> TComplexScalar_co:
121-
return self.to_native_dtype().type(data) # type: ignore[return-value]
121+
return self.to_native_dtype().type(data)
122122

123123
def cast_scalar(self, data: object) -> TComplexScalar_co:
124124
if self._check_scalar(data):

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def from_native_dtype(cls, dtype: TBaseDType) -> Self:
4848

4949
def to_native_dtype(self) -> TFloatDType_co:
5050
byte_order = endianness_to_numpy_str(self.endianness)
51-
return self.dtype_cls().newbyteorder(byte_order) # type: ignore[return-value]
51+
return self.dtype_cls().newbyteorder(byte_order)
5252

5353
@classmethod
5454
def _check_json_v2(cls, data: DTypeJSON) -> TypeGuard[DTypeConfig_V2[str, None]]:
@@ -112,7 +112,7 @@ def _check_scalar(self, data: object) -> TypeGuard[FloatLike]:
112112
return isinstance(data, FloatLike)
113113

114114
def _cast_scalar_unchecked(self, data: FloatLike) -> TFloatScalar_co:
115-
return self.to_native_dtype().type(data) # type: ignore[return-value]
115+
return self.to_native_dtype().type(data)
116116

117117
def cast_scalar(self, data: object) -> TFloatScalar_co:
118118
if self._check_scalar(data):

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def _cast_scalar_unchecked(self, data: IntLike) -> TIntScalar_co:
8484
"""
8585
Create an integer without any type checking of the input.
8686
"""
87-
return self.to_native_dtype().type(data) # type: ignore[return-value]
87+
return self.to_native_dtype().type(data)
8888

8989
def cast_scalar(self, data: object) -> TIntScalar_co:
9090
if self._check_scalar(data):

0 commit comments

Comments
 (0)