Skip to content

Commit b4cdf94

Browse files
dstansbyjhamman
andauthored
Enable extra mypy error codes (#1909)
* Clean up v2 mypy ignores * Enable extra mypy error codes * Specific error code --------- Co-authored-by: Joe Hamman <joe@earthmover.io>
1 parent 016964b commit b4cdf94

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ namespace_packages = false
190190
strict = true
191191

192192

193+
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
194+
193195
[[tool.mypy.overrides]]
194196
module = [
195197
"zarr.v2.*",

src/zarr/buffer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def ravel(self, order: Literal["K", "A", "C", "F"] = "C") -> Self: ...
7979

8080
def all(self) -> bool: ...
8181

82-
def __eq__(self, other: Any) -> Self: # type: ignore
82+
def __eq__(self, other: Any) -> Self: # type: ignore[explicit-override, override]
8383
"""Element-wise equal
8484
8585
Notice

src/zarr/codecs/sharding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def merge_with_morton_order(
205205
) -> _ShardBuilder:
206206
obj = cls.create_empty(chunks_per_shard)
207207
for chunk_coords in morton_order_iter(chunks_per_shard):
208-
if tombstones is not None and chunk_coords in tombstones:
208+
if chunk_coords in tombstones:
209209
continue
210210
for shard_dict in shard_dicts:
211211
maybe_value = shard_dict.get(chunk_coords, None)

src/zarr/indexing.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,8 @@ def is_total_slice(item: Selection, shape: ChunkCoords) -> bool:
199199
if isinstance(item, tuple):
200200
return all(
201201
(
202-
isinstance(dim_sel, slice)
203-
and (
204-
(dim_sel == slice(None))
205-
or ((dim_sel.stop - dim_sel.start == dim_len) and (dim_sel.step in [1, None]))
206-
)
202+
(dim_sel == slice(None))
203+
or ((dim_sel.stop - dim_sel.start == dim_len) and (dim_sel.step in [1, None]))
207204
)
208205
for dim_sel, dim_len in zip(item, shape, strict=False)
209206
)

src/zarr/metadata.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,11 @@ def update_attributes(self, attributes: dict[str, JSON]) -> Self:
432432
def parse_dimension_names(data: None | Iterable[str]) -> tuple[str, ...] | None:
433433
if data is None:
434434
return data
435-
if isinstance(data, Iterable) and all([isinstance(x, str) for x in data]):
435+
elif all([isinstance(x, str) for x in data]):
436436
return tuple(data)
437-
msg = f"Expected either None or a iterable of str, got {type(data)}"
438-
raise TypeError(msg)
437+
else:
438+
msg = f"Expected either None or a iterable of str, got {type(data)}"
439+
raise TypeError(msg)
439440

440441

441442
# todo: real validation

src/zarr/testing/store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_store_mode(self, store: S, store_kwargs: dict[str, Any]) -> None:
4747
assert store.writeable
4848

4949
with pytest.raises(AttributeError):
50-
store.mode = "w" # type: ignore
50+
store.mode = "w" # type: ignore[misc]
5151

5252
# read-only
5353
kwargs = {**store_kwargs, "mode": "r"}

0 commit comments

Comments
 (0)