Skip to content

Commit 3835768

Browse files
committed
fix mypy in test_array.py
1 parent 584762b commit 3835768

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

tests/test_api.py

Lines changed: 4 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() # type: ignore [union-attr]
240+
assert (z2[:] == 1).all() # type: ignore [union-attr]
241241
with pytest.raises(ValueError):
242242
z2[:] = 3
243243

@@ -250,7 +250,7 @@ def test_open_with_mode_r_plus(tmp_path: pathlib.Path) -> None:
250250
z2 = zarr.open(store=tmp_path, mode="r+")
251251
assert isinstance(z2, Array)
252252
assert isinstance(z2[:], NDArrayLike)
253-
assert (z2[:] == 1).all() # type: ignore [union-attr]
253+
assert (z2[:] == 1).all() # type: ignore [union-attr]
254254
z2[:] = 3
255255

256256

@@ -267,7 +267,7 @@ async def test_open_with_mode_a(tmp_path: pathlib.Path) -> None:
267267
z2 = zarr.open(store=tmp_path, mode="a")
268268
assert isinstance(z2, Array)
269269
assert isinstance(z2[:], NDArrayLike)
270-
assert (z2[:] == 1).all() # type: ignore [union-attr]
270+
assert (z2[:] == 1).all() # type: ignore [union-attr]
271271
z2[:] = 3
272272

273273

@@ -280,7 +280,7 @@ def test_open_with_mode_w(tmp_path: pathlib.Path) -> None:
280280
z2 = zarr.open(store=tmp_path, mode="w", shape=(3, 3))
281281
assert isinstance(z2, Array)
282282
assert isinstance(z2[:], NDArrayLike)
283-
assert (z2[:] == 3).all() # type: ignore [union-attr]
283+
assert (z2[:] == 3).all() # type: ignore [union-attr]
284284
z2[:] = 3
285285

286286

tests/test_array.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
create_array,
3939
)
4040
from zarr.core.buffer import default_buffer_prototype
41-
from zarr.core.buffer.core import NDArrayLike
4241
from zarr.core.buffer.cpu import NDBuffer
4342
from zarr.core.chunk_grids import _auto_partition
4443
from zarr.core.common import JSON, MemoryOrder, ZarrFormat
@@ -656,10 +655,9 @@ def test_resize_1d(store: MemoryStore, zarr_format: ZarrFormat) -> None:
656655
a = np.arange(105, dtype="i4")
657656
z[:] = a
658657
assert (105,) == z.shape
659-
assert hasattr(z[:], "shape") and hasattr(z[:], "dtype")
660-
assert (105,) == z[:].shape
658+
assert hasattr(z[:], "shape") and (105,) == z[:].shape
661659
assert np.dtype("i4") == z.dtype
662-
assert np.dtype("i4") == z[:].dtype
660+
assert hasattr(z[:], "dtype") and np.dtype("i4") == z[:].dtype
663661
assert (10,) == z.chunks
664662
np.testing.assert_array_equal(a, z[:])
665663

tests/test_buffer.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@ async def test_async_array_prototype() -> None:
6565
prototype=my_prototype,
6666
)
6767
got = await a.getitem(selection=(slice(0, 9), slice(0, 9)), prototype=my_prototype)
68-
# ignoring a mypy error here that TestNDArrayLike doesn't meet the NDArrayLike protocol
69-
# The test passes, so it clearly does.
70-
assert isinstance(got, TestNDArrayLike) # type: ignore[unreachable]
71-
assert np.array_equal(expect, got) # type: ignore[unreachable]
68+
assert isinstance(got, TestNDArrayLike)
69+
assert np.array_equal(expect, got)
7270

7371

7472
@gpu_test

0 commit comments

Comments
 (0)