Skip to content

Commit a9c0eab

Browse files
committed
fix mypy
1 parent 422e0d8 commit a9c0eab

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/zarr/core/buffer/core.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
NamedTuple,
1010
Protocol,
1111
SupportsIndex,
12-
Union,
1312
cast,
1413
runtime_checkable,
1514
)
@@ -107,7 +106,8 @@ def __eq__(self, other: object) -> Self: # type: ignore[explicit-override, over
107106
"""
108107

109108

110-
NDArrayOrScalarLike = "np.ScalarType" | NDArrayLike
109+
ScalarType = int | float | complex | bool | np.generic
110+
NDArrayOrScalarLike = ScalarType | NDArrayLike
111111

112112

113113
class ScalarWrapper:
@@ -556,7 +556,7 @@ def as_numpy_array(self) -> npt.NDArray[Any]:
556556
"""
557557
...
558558

559-
def as_scalar(self) -> np.ScalarType:
559+
def as_scalar(self) -> ScalarType:
560560
"""Returns the buffer as a scalar value
561561
562562
Returns
@@ -565,7 +565,8 @@ def as_scalar(self) -> np.ScalarType:
565565
"""
566566
if self._data.size != 1:
567567
raise ValueError("Buffer does not contain a single scalar value")
568-
return self.dtype.type(self.as_numpy_array().item())
568+
value: ScalarType = self.dtype.type(self.as_numpy_array().item())
569+
return value
569570

570571
@property
571572
def dtype(self) -> np.dtype[Any]:

0 commit comments

Comments
 (0)