Skip to content

Commit 666abc9

Browse files
Abstract method should raise NotImplementedError
1 parent 4cbb17e commit 666abc9

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

src/zarr/abc/codec.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,17 @@ def from_codecs(cls, codecs: Iterable[Codec]) -> Self:
276276
-------
277277
Self
278278
"""
279-
...
279+
raise NotImplementedError
280280

281281
@property
282282
@abstractmethod
283-
def supports_partial_decode(self) -> bool: ...
283+
def supports_partial_decode(self) -> bool:
284+
raise NotImplementedError
284285

285286
@property
286287
@abstractmethod
287-
def supports_partial_encode(self) -> bool: ...
288+
def supports_partial_encode(self) -> bool:
289+
raise NotImplementedError
288290

289291
@abstractmethod
290292
def validate(self, *, shape: ChunkCoords, dtype: np.dtype[Any], chunk_grid: ChunkGrid) -> None:
@@ -300,7 +302,7 @@ def validate(self, *, shape: ChunkCoords, dtype: np.dtype[Any], chunk_grid: Chun
300302
chunk_grid: ChunkGrid
301303
The array chunk grid
302304
"""
303-
...
305+
raise NotImplementedError
304306

305307
@abstractmethod
306308
def compute_encoded_size(self, byte_length: int, array_spec: ArraySpec) -> int:
@@ -316,7 +318,7 @@ def compute_encoded_size(self, byte_length: int, array_spec: ArraySpec) -> int:
316318
-------
317319
int
318320
"""
319-
...
321+
raise NotImplementedError
320322

321323
@abstractmethod
322324
async def decode(
@@ -335,7 +337,7 @@ async def decode(
335337
-------
336338
Iterable[NDBuffer | None]
337339
"""
338-
...
340+
raise NotImplementedError
339341

340342
@abstractmethod
341343
async def encode(
@@ -354,7 +356,7 @@ async def encode(
354356
-------
355357
Iterable[Buffer | None]
356358
"""
357-
...
359+
raise NotImplementedError
358360

359361
@abstractmethod
360362
async def read(
@@ -376,7 +378,7 @@ async def read(
376378
The chunk spec contains information about the construction of an array from the bytes.
377379
out : NDBuffer
378380
"""
379-
...
381+
raise NotImplementedError
380382

381383
@abstractmethod
382384
async def write(
@@ -399,7 +401,7 @@ async def write(
399401
The chunk spec contains information about the chunk.
400402
value : NDBuffer
401403
"""
402-
...
404+
raise NotImplementedError
403405

404406

405407
async def _batching_helper(

src/zarr/core/buffer/core.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def as_numpy_array(self) -> npt.NDArray[Any]:
419419
-------
420420
NumPy array of this buffer (might be a data copy)
421421
"""
422-
...
422+
raise NotImplementedError
423423

424424
@property
425425
def dtype(self) -> np.dtype[Any]:
@@ -451,10 +451,12 @@ def astype(self, dtype: npt.DTypeLike, order: Literal["K", "A", "C", "F"] = "K")
451451
return self.__class__(self._data.astype(dtype=dtype, order=order))
452452

453453
@abstractmethod
454-
def __getitem__(self, key: Any) -> Self: ...
454+
def __getitem__(self, key: Any) -> Self:
455+
raise NotImplementedError
455456

456457
@abstractmethod
457-
def __setitem__(self, key: Any, value: Any) -> None: ...
458+
def __setitem__(self, key: Any, value: Any) -> None:
459+
raise NotImplementedError
458460

459461
def __len__(self) -> int:
460462
return self._data.__len__()

src/zarr/core/chunk_grids.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ def from_dict(cls, data: dict[str, JSON] | ChunkGrid) -> ChunkGrid:
112112

113113
@abstractmethod
114114
def all_chunk_coords(self, array_shape: ChunkCoords) -> Iterator[ChunkCoords]:
115-
pass
115+
raise NotImplementedError
116116

117117
@abstractmethod
118118
def get_nchunks(self, array_shape: ChunkCoords) -> int:
119-
pass
119+
raise NotImplementedError
120120

121121

122122
@dataclass(frozen=True)

src/zarr/core/chunk_key_encodings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ def to_dict(self) -> dict[str, JSON]:
5555

5656
@abstractmethod
5757
def decode_chunk_key(self, chunk_key: str) -> ChunkCoords:
58-
pass
58+
raise NotImplementedError
5959

6060
@abstractmethod
6161
def encode_chunk_key(self, chunk_coords: ChunkCoords) -> str:
62-
pass
62+
raise NotImplementedError
6363

6464

6565
@dataclass(frozen=True)

0 commit comments

Comments
 (0)