Skip to content

Commit

Permalink
fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
brokkoli71 committed Feb 12, 2025
1 parent 422e0d8 commit a9c0eab
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/zarr/core/buffer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
NamedTuple,
Protocol,
SupportsIndex,
Union,
cast,
runtime_checkable,
)
Expand Down Expand Up @@ -107,7 +106,8 @@ def __eq__(self, other: object) -> Self: # type: ignore[explicit-override, over
"""


NDArrayOrScalarLike = "np.ScalarType" | NDArrayLike
ScalarType = int | float | complex | bool | np.generic
NDArrayOrScalarLike = ScalarType | NDArrayLike


class ScalarWrapper:
Expand Down Expand Up @@ -556,7 +556,7 @@ def as_numpy_array(self) -> npt.NDArray[Any]:
"""
...

def as_scalar(self) -> np.ScalarType:
def as_scalar(self) -> ScalarType:
"""Returns the buffer as a scalar value
Returns
Expand All @@ -565,7 +565,8 @@ def as_scalar(self) -> np.ScalarType:
"""
if self._data.size != 1:
raise ValueError("Buffer does not contain a single scalar value")
return self.dtype.type(self.as_numpy_array().item())
value: ScalarType = self.dtype.type(self.as_numpy_array().item())
return value

@property
def dtype(self) -> np.dtype[Any]:
Expand Down

0 comments on commit a9c0eab

Please sign in to comment.