Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable extra mypy error codes #1909

Merged
merged 4 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ namespace_packages = false
strict = true


enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]

[[tool.mypy.overrides]]
module = [
"zarr.v2.*",
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def ravel(self, order: Literal["K", "A", "C", "F"] = "C") -> Self: ...

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

def __eq__(self, other: Any) -> Self: # type: ignore
def __eq__(self, other: Any) -> Self: # type: ignore[explicit-override, override]
"""Element-wise equal

Notice
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/codecs/sharding.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def merge_with_morton_order(
) -> _ShardBuilder:
obj = cls.create_empty(chunks_per_shard)
for chunk_coords in morton_order_iter(chunks_per_shard):
if tombstones is not None and chunk_coords in tombstones:
if chunk_coords in tombstones:
continue
for shard_dict in shard_dicts:
maybe_value = shard_dict.get(chunk_coords, None)
Expand Down
7 changes: 2 additions & 5 deletions src/zarr/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,8 @@ def is_total_slice(item: Selection, shape: ChunkCoords) -> bool:
if isinstance(item, tuple):
return all(
(
isinstance(dim_sel, slice)
and (
(dim_sel == slice(None))
or ((dim_sel.stop - dim_sel.start == dim_len) and (dim_sel.step in [1, None]))
)
(dim_sel == slice(None))
or ((dim_sel.stop - dim_sel.start == dim_len) and (dim_sel.step in [1, None]))
)
for dim_sel, dim_len in zip(item, shape, strict=False)
)
Expand Down
7 changes: 4 additions & 3 deletions src/zarr/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,11 @@ def update_attributes(self, attributes: dict[str, JSON]) -> Self:
def parse_dimension_names(data: None | Iterable[str]) -> tuple[str, ...] | None:
if data is None:
return data
if isinstance(data, Iterable) and all([isinstance(x, str) for x in data]):
elif all([isinstance(x, str) for x in data]):
return tuple(data)
msg = f"Expected either None or a iterable of str, got {type(data)}"
raise TypeError(msg)
else:
msg = f"Expected either None or a iterable of str, got {type(data)}"
raise TypeError(msg)


# todo: real validation
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/testing/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_store_mode(self, store: S, store_kwargs: dict[str, Any]) -> None:
assert store.writeable

with pytest.raises(AttributeError):
store.mode = "w" # type: ignore
store.mode = "w" # type: ignore[misc]

# read-only
kwargs = {**store_kwargs, "mode": "r"}
Expand Down
Loading