Skip to content

Commit 0886e77

Browse files
committed
fix mypy in test_api.py and synchronous.py
1 parent ada708e commit 0886e77

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/zarr/api/synchronous.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import zarr.core.array
99
from zarr._compat import _deprecate_positional_args
1010
from zarr.core.array import Array, AsyncArray
11+
from zarr.core.buffer.core import NDArrayLike
1112
from zarr.core.group import Group
1213
from zarr.core.sync import sync
1314

@@ -216,7 +217,7 @@ def open_consolidated(*args: Any, use_consolidated: Literal[True] = True, **kwar
216217

217218
def save(
218219
store: StoreLike,
219-
*args: NDArrayOrScalarLike,
220+
*args: NDArrayLike,
220221
zarr_version: ZarrFormat | None = None, # deprecated
221222
zarr_format: ZarrFormat | None = None,
222223
path: str | None = None,
@@ -247,7 +248,7 @@ def save(
247248
@_deprecate_positional_args
248249
def save_array(
249250
store: StoreLike,
250-
arr: NDArrayOrScalarLike,
251+
arr: NDArrayLike,
251252
*,
252253
zarr_version: ZarrFormat | None = None, # deprecated
253254
zarr_format: ZarrFormat | None = None,
@@ -290,12 +291,12 @@ def save_array(
290291

291292
def save_group(
292293
store: StoreLike,
293-
*args: NDArrayOrScalarLike,
294+
*args: NDArrayLike,
294295
zarr_version: ZarrFormat | None = None, # deprecated
295296
zarr_format: ZarrFormat | None = None,
296297
path: str | None = None,
297298
storage_options: dict[str, Any] | None = None,
298-
**kwargs: NDArrayOrScalarLike,
299+
**kwargs: NDArrayLike,
299300
) -> None:
300301
"""Save several NumPy arrays to the local file system.
301302

tests/test_api.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def test_open_with_mode_r(tmp_path: pathlib.Path) -> None:
237237
assert isinstance(z2, Array)
238238
assert z2.fill_value == 1
239239
assert isinstance(z2[:], NDArrayLike)
240-
assert (z2[:] == 1).all()
240+
assert (z2[:] == 1).all() # type: ignore [operator]
241241
with pytest.raises(ValueError):
242242
z2[:] = 3
243243

@@ -249,7 +249,8 @@ def test_open_with_mode_r_plus(tmp_path: pathlib.Path) -> None:
249249
zarr.ones(store=tmp_path, shape=(3, 3))
250250
z2 = zarr.open(store=tmp_path, mode="r+")
251251
assert isinstance(z2, Array)
252-
assert (z2[:] == 1).all()
252+
assert isinstance(z2[:], NDArrayLike)
253+
assert (z2[:] == 1).all() # type: ignore [operator]
253254
z2[:] = 3
254255

255256

@@ -265,7 +266,8 @@ async def test_open_with_mode_a(tmp_path: pathlib.Path) -> None:
265266
arr[...] = 1
266267
z2 = zarr.open(store=tmp_path, mode="a")
267268
assert isinstance(z2, Array)
268-
assert (z2[:] == 1).all()
269+
assert isinstance(z2[:], NDArrayLike)
270+
assert (z2[:] == 1).all() # type: ignore [operator]
269271
z2[:] = 3
270272

271273

@@ -277,7 +279,8 @@ def test_open_with_mode_w(tmp_path: pathlib.Path) -> None:
277279
arr[...] = 3
278280
z2 = zarr.open(store=tmp_path, mode="w", shape=(3, 3))
279281
assert isinstance(z2, Array)
280-
assert not (z2[:] == 3).all()
282+
assert isinstance(z2[:], NDArrayLike)
283+
assert (z2[:] == 3).all() # type: ignore [operator]
281284
z2[:] = 3
282285

283286

0 commit comments

Comments
 (0)