Skip to content

Commit 632cad0

Browse files
committed
fix typing
1 parent a7d4421 commit 632cad0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/zarr/core/buffer/core.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
from zarr.codecs.bytes import Endian
2424
from zarr.core.common import BytesLike, ChunkCoords
25+
from zarr.core.indexing import Selection
2526

2627
# Everything here is imported into ``zarr.core.buffer`` namespace.
2728
__all__: list[str] = []
@@ -129,12 +130,12 @@ def shape(self) -> tuple[()]:
129130
def __len__(self) -> int:
130131
raise TypeError("len() of unsized object.")
131132

132-
def __getitem__(self, key: slice) -> Self:
133+
def __getitem__(self, key: Selection) -> Self:
133134
if key != slice(None) and key != Ellipsis and key != ():
134135
raise IndexError("Invalid index for scalar.")
135136
return self
136137

137-
def __setitem__(self, key: slice, value: Any) -> None:
138+
def __setitem__(self, key: Selection, value: Any) -> None:
138139
if key != slice(None) and key != Ellipsis and key != ():
139140
raise IndexError("Invalid index for scalar.")
140141
self._value = value
@@ -560,7 +561,7 @@ def as_scalar(self) -> ScalarWrapper:
560561
"""
561562
if self._data.size != 1:
562563
raise ValueError("Buffer does not contain a single scalar value")
563-
return ScalarWrapper(self.as_numpy_array().item(), self.dtype)
564+
return ScalarWrapper(self.as_numpy_array().item(), np.dtype(self.dtype))
564565

565566
@property
566567
def dtype(self) -> np.dtype[Any]:

0 commit comments

Comments
 (0)