Skip to content

Commit

Permalink
Enable extra mypy error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
dstansby committed May 24, 2024
1 parent 11f1e6d commit 52351c6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ disallow_untyped_calls = true

disallow_untyped_defs = true

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

[[tool.mypy.overrides]]
module = [
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 @@ -206,7 +206,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 @@ -429,10 +429,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

0 comments on commit 52351c6

Please sign in to comment.