Skip to content

Commit ada708e

Browse files
committed
fix mypy in test_api.py
1 parent 73c835f commit ada708e

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

src/zarr/api/asynchronous.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from zarr.core.array import Array, AsyncArray, create_array, get_array_metadata
1313
from zarr.core.array_spec import ArrayConfig, ArrayConfigLike
14-
from zarr.core.buffer import NDArrayOrScalarLike
14+
from zarr.core.buffer.core import NDArrayLike
1515
from zarr.core.common import (
1616
JSON,
1717
AccessModeLiteral,
@@ -33,7 +33,7 @@
3333
from collections.abc import Iterable
3434

3535
from zarr.abc.codec import Codec
36-
from zarr.core.buffer.core import NDArrayLike
36+
from zarr.core.buffer import NDArrayOrScalarLike
3737
from zarr.core.chunk_key_encodings import ChunkKeyEncoding
3838
from zarr.storage import StoreLike
3939

@@ -481,9 +481,7 @@ async def save_group(
481481
)
482482
for k, v in kwargs.items():
483483
if not isinstance(v, NDArrayLike):
484-
raise TypeError(
485-
f"Keyword argument '{k}' must be a numpy or other NDArrayLike array"
486-
)
484+
raise TypeError(f"Keyword argument '{k}' must be a numpy or other NDArrayLike array")
487485

488486
if len(args) == 0 and len(kwargs) == 0:
489487
raise ValueError("at least one array must be provided")

tests/test_api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
save_array,
2424
save_group,
2525
)
26+
from zarr.core.buffer.core import NDArrayLike
2627
from zarr.core.common import JSON, MemoryOrder, ZarrFormat
2728
from zarr.errors import MetadataValidationError
2829
from zarr.storage import MemoryStore
@@ -235,6 +236,7 @@ def test_open_with_mode_r(tmp_path: pathlib.Path) -> None:
235236
z2 = zarr.open(store=tmp_path, mode="r")
236237
assert isinstance(z2, Array)
237238
assert z2.fill_value == 1
239+
assert isinstance(z2[:], NDArrayLike)
238240
assert (z2[:] == 1).all()
239241
with pytest.raises(ValueError):
240242
z2[:] = 3

tests/test_array.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,13 +1394,6 @@ def test_roundtrip_numcodecs() -> None:
13941394
assert metadata["codecs"] == expected
13951395

13961396

1397-
def test_tmp():
1398-
a = np.array(1)
1399-
print(type(a[()]))
1400-
z = zarr.array(a, store=MemoryStore())
1401-
print(type(z[()]))
1402-
1403-
14041397
def _index_array(arr: Array, index: Any) -> Any:
14051398
return arr[index]
14061399

tests/test_buffer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
from zarr.codecs.gzip import GzipCodec
1212
from zarr.codecs.transpose import TransposeCodec
1313
from zarr.codecs.zstd import ZstdCodec
14-
from zarr.core.buffer import ArrayLike, BufferPrototype, NDArrayLike, cpu, gpu
14+
from zarr.core.buffer import ArrayLike, BufferPrototype, cpu, gpu
15+
from zarr.core.buffer.core import NDArrayLike
1516
from zarr.storage import MemoryStore, StorePath
1617
from zarr.testing.buffer import (
1718
NDBufferUsingTestNDArrayLike,

0 commit comments

Comments
 (0)