Skip to content

Commit 7d78645

Browse files
author
Cipher
committed
fix(mypy): correct type-ignore codes for union attribute access in sharding test
- Line 542: Fix assert accessing .shape by changing from [index] to [union-attr] - Line 544: Add missing type-ignore[union-attr] for f-string .shape access - Lines 554-555: Remove unused type-ignore[index] comments on assignments The mypy errors were caused by indexing operations returning union types that include scalar types (int, float, etc.), which don't have a .shape attribute. The proper fix uses type-ignore[union-attr] for attribute access, not [index].
1 parent 4f332c4 commit 7d78645

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

tests/test_codecs/test_sharding.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def test_sharding_mixed_integer_list_indexing(store: Store) -> None:
539539
# Mixed integer + list indexing
540540
c = chunked[0:10, 0, [0, 1]] # type: ignore[index]
541541
s = sharded[0:10, 0, [0, 1]] # type: ignore[index]
542-
assert c.shape == s.shape == (10, 2), ( # type: ignore[index]
542+
assert c.shape == s.shape == (10, 2), ( # type: ignore[union-attr]
543543
f"Expected (10, 2), got chunked={c.shape}, sharded={s.shape}" # type: ignore[union-attr]
544544
)
545545
np.testing.assert_array_equal(c, s)
@@ -551,7 +551,7 @@ def test_sharding_mixed_integer_list_indexing(store: Store) -> None:
551551
np.testing.assert_array_equal(c2, s2)
552552

553553
# Slice + integer + slice
554-
c3 = chunked[0:5, 1, 0:3] # type: ignore[index]
555-
s3 = sharded[0:5, 1, 0:3] # type: ignore[index]
554+
c3 = chunked[0:5, 1, 0:3]
555+
s3 = sharded[0:5, 1, 0:3]
556556
assert c3.shape == s3.shape == (5, 3) # type: ignore[union-attr]
557557
np.testing.assert_array_equal(c3, s3)

0 commit comments

Comments
 (0)