diff --git a/pyproject.toml b/pyproject.toml index 616c388f99..9f50c33db0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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.*", diff --git a/src/zarr/buffer.py b/src/zarr/buffer.py index 0f055093c1..59994e70d6 100644 --- a/src/zarr/buffer.py +++ b/src/zarr/buffer.py @@ -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 diff --git a/src/zarr/codecs/sharding.py b/src/zarr/codecs/sharding.py index cea788840d..a7b6edc3b4 100644 --- a/src/zarr/codecs/sharding.py +++ b/src/zarr/codecs/sharding.py @@ -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) diff --git a/src/zarr/indexing.py b/src/zarr/indexing.py index 45413bc5b2..6bc83d5062 100644 --- a/src/zarr/indexing.py +++ b/src/zarr/indexing.py @@ -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) ) diff --git a/src/zarr/metadata.py b/src/zarr/metadata.py index 2d8a455152..29d0d19a06 100644 --- a/src/zarr/metadata.py +++ b/src/zarr/metadata.py @@ -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 diff --git a/src/zarr/testing/store.py b/src/zarr/testing/store.py index b317f383f6..cb4dc9f7b5 100644 --- a/src/zarr/testing/store.py +++ b/src/zarr/testing/store.py @@ -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"}