Skip to content

Commit 669ad72

Browse files
committed
np.dtype[np.generic] -> np.dtype[Any]
1 parent dba2594 commit 669ad72

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

src/zarr/codecs/sharding.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,7 @@ def evolve_from_array_spec(self, array_spec: ArraySpec) -> Self:
396396
return replace(self, codecs=evolved_codecs)
397397
return self
398398

399-
def validate(
400-
self, *, shape: ChunkCoords, dtype: np.dtype[np.generic], chunk_grid: ChunkGrid
401-
) -> None:
399+
def validate(self, *, shape: ChunkCoords, dtype: np.dtype[Any], chunk_grid: ChunkGrid) -> None:
402400
if len(self.chunk_shape) != len(shape):
403401
raise ValueError(
404402
"The shard's `chunk_shape` and array's `shape` need to have the same number of dimensions."

src/zarr/core/array.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3686,7 +3686,7 @@ def _get_default_encoding_v3(
36863686

36873687

36883688
def _get_default_chunk_encoding_v2(
3689-
dtype: np.dtype[np.generic],
3689+
dtype: np.dtype[Any],
36903690
) -> tuple[tuple[numcodecs.abc.Codec, ...], numcodecs.abc.Codec]:
36913691
"""
36923692
Get the default chunk encoding for zarr v2 arrays, given a dtype
@@ -3718,7 +3718,7 @@ def _parse_chunk_encoding_v2(
37183718
*,
37193719
compression: numcodecs.abc.Codec | Literal["auto"],
37203720
filters: tuple[numcodecs.abc.Codec, ...] | Literal["auto"],
3721-
dtype: np.dtype[np.generic],
3721+
dtype: np.dtype[Any],
37223722
) -> tuple[tuple[numcodecs.abc.Codec, ...], numcodecs.abc.Codec]:
37233723
"""
37243724
Generate chunk encoding classes for v2 arrays with optional defaults.
@@ -3740,7 +3740,7 @@ def _parse_chunk_encoding_v3(
37403740
*,
37413741
compression: Iterable[BytesBytesCodec] | Literal["auto"],
37423742
filters: Iterable[ArrayArrayCodec] | Literal["auto"],
3743-
dtype: np.dtype[np.generic],
3743+
dtype: np.dtype[Any],
37443744
) -> tuple[tuple[ArrayArrayCodec, ...], ArrayBytesCodec, tuple[BytesBytesCodec, ...]]:
37453745
"""
37463746
Generate chunk encoding classes for v3 arrays with optional defaults.

src/zarr/core/chunk_grids.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def _auto_partition(
200200
array_shape: tuple[int, ...],
201201
shard_shape: tuple[int, ...] | Literal["auto"] | None,
202202
chunk_shape: tuple[int, ...] | Literal["auto"],
203-
dtype: np.dtype[np.generic],
203+
dtype: np.dtype[Any],
204204
) -> tuple[tuple[int, ...] | None, tuple[int, ...]]:
205205
"""
206206
Automatically determine the shard shape and chunk shape for an array, given the shape and dtype of the array.

src/zarr/core/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def parse_bool(data: Any) -> bool:
168168
raise ValueError(f"Expected bool, got {data} instead.")
169169

170170

171-
def parse_dtype(dtype: Any, zarr_format: ZarrFormat) -> np.dtype[np.generic]:
171+
def parse_dtype(dtype: Any, zarr_format: ZarrFormat) -> np.dtype[Any]:
172172
if dtype is str or dtype == "str":
173173
if zarr_format == 2:
174174
# special case as object

src/zarr/core/metadata/v3.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ def parse_fill_value(
449449
return np.bytes_(fill_value)
450450

451451
# the rest are numeric types
452-
np_dtype = cast(np.dtype[np.generic], data_type.to_numpy())
452+
np_dtype = cast(np.dtype[Any], data_type.to_numpy())
453453

454454
if isinstance(fill_value, Sequence) and not isinstance(fill_value, str):
455455
if data_type in (DataType.complex64, DataType.complex128):
@@ -513,7 +513,7 @@ def default_fill_value(dtype: DataType) -> str | bytes | np.generic:
513513
return b""
514514
else:
515515
np_dtype = dtype.to_numpy()
516-
np_dtype = cast(np.dtype[np.generic], np_dtype)
516+
np_dtype = cast(np.dtype[Any], np_dtype)
517517
return np_dtype.type(0)
518518

519519

@@ -586,7 +586,7 @@ def to_numpy_shortname(self) -> str:
586586
}
587587
return data_type_to_numpy[self]
588588

589-
def to_numpy(self) -> np.dtypes.StringDType | np.dtypes.ObjectDType | np.dtype[np.generic]:
589+
def to_numpy(self) -> np.dtypes.StringDType | np.dtypes.ObjectDType | np.dtype[Any]:
590590
# note: it is not possible to round trip DataType <-> np.dtype
591591
# due to the fact that DataType.string and DataType.bytes both
592592
# generally return np.dtype("O") from this function, even though

0 commit comments

Comments
 (0)