diff --git a/pyproject.toml b/pyproject.toml index b4783b5be3..18b3a37979 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -319,6 +319,8 @@ extend-select = [ "PERF", # Perflint "PIE", # flake8-pie "PGH", # pygrep-hooks + "PLE", # Pylint Error + "PLR", # Pylint Refactor "PT", # flake8-pytest-style "PYI", # flake8-pyi "RET", # flake8-return @@ -333,6 +335,15 @@ extend-select = [ ] ignore = [ "ANN401", + "PLR0124", + "PLR0904", + "PLR0911", + "PLR0912", + "PLR0913", + "PLR0914", + "PLR0915", + "PLR0917", + "PLR2004", "PT011", # TODO: apply this rule "RET505", "RET506", diff --git a/src/zarr/core/array.py b/src/zarr/core/array.py index f0cd5dd734..99c8ed9307 100644 --- a/src/zarr/core/array.py +++ b/src/zarr/core/array.py @@ -2119,7 +2119,7 @@ def filters(self) -> tuple[Numcodec, ...] | tuple[ArrayArrayCodec, ...]: return self.async_array.filters @property - def serializer(self) -> None | ArrayBytesCodec: + def serializer(self) -> ArrayBytesCodec | None: """ Array-to-bytes codec to use for serializing the chunks into bytes. """ diff --git a/src/zarr/core/chunk_grids.py b/src/zarr/core/chunk_grids.py index 3d7313cd5d..3129f9b9e9 100644 --- a/src/zarr/core/chunk_grids.py +++ b/src/zarr/core/chunk_grids.py @@ -743,7 +743,7 @@ def _auto_partition( given the dtype and shard shape. Otherwise, the chunks will be returned as-is. """ if shard_shape is None: - _shards_out: None | tuple[int, ...] = None + _shards_out: tuple[int, ...] | None = None if chunk_shape == "auto": _chunks_out = _guess_chunks(array_shape, item_size) else: diff --git a/src/zarr/core/codec_pipeline.py b/src/zarr/core/codec_pipeline.py index 4cecc3a6d1..21381594ae 100644 --- a/src/zarr/core/codec_pipeline.py +++ b/src/zarr/core/codec_pipeline.py @@ -529,13 +529,12 @@ async def _read_key( ): if chunk_array is None: chunk_array_batch.append(None) # type: ignore[unreachable] + elif not chunk_spec.config.write_empty_chunks and chunk_array.all_equal( + fill_value_or_default(chunk_spec) + ): + chunk_array_batch.append(None) else: - if not chunk_spec.config.write_empty_chunks and chunk_array.all_equal( - fill_value_or_default(chunk_spec) - ): - chunk_array_batch.append(None) - else: - chunk_array_batch.append(chunk_array) + chunk_array_batch.append(chunk_array) chunk_bytes_batch = await self.encode_batch( [ diff --git a/src/zarr/core/group.py b/src/zarr/core/group.py index b810041e7b..909f2e4f42 100644 --- a/src/zarr/core/group.py +++ b/src/zarr/core/group.py @@ -3450,7 +3450,7 @@ def _parse_hierarchy_dict( # but not if an empty dict was provided, because any empty hierarchy has no nodes if len(data_normed_keys) > 0 and "" not in data_normed_keys: z_format = next(iter(data_normed_keys.values())).zarr_format - data_normed_keys = data_normed_keys | {"": ImplicitGroupMarker(zarr_format=z_format)} + data_normed_keys |= {"": ImplicitGroupMarker(zarr_format=z_format)} out: dict[str, GroupMetadata | ArrayV2Metadata | ArrayV3Metadata] = {**data_normed_keys} diff --git a/src/zarr/testing/stateful.py b/src/zarr/testing/stateful.py index d6c43f4ecc..3adb272132 100644 --- a/src/zarr/testing/stateful.py +++ b/src/zarr/testing/stateful.py @@ -308,8 +308,8 @@ def delete_dir(self, data: DataObject) -> None: for node in self.all_groups | self.all_arrays: if node.startswith(path): matches.add(node) - self.all_groups = self.all_groups - matches - self.all_arrays = self.all_arrays - matches + self.all_groups -= matches + self.all_arrays -= matches # @precondition(lambda self: bool(self.all_groups)) # @precondition(lambda self: bool(self.all_arrays)) diff --git a/src/zarr/testing/strategies.py b/src/zarr/testing/strategies.py index e382235e0e..aacfbd8cd6 100644 --- a/src/zarr/testing/strategies.py +++ b/src/zarr/testing/strategies.py @@ -124,7 +124,7 @@ def clear_store(x: Store) -> Store: @st.composite -def dimension_names(draw: st.DrawFn, *, ndim: int | None = None) -> list[None | str] | None: +def dimension_names(draw: st.DrawFn, *, ndim: int | None = None) -> list[str | None] | None: simple_text = st.text(zarr_key_chars, min_size=0) return draw(st.none() | st.lists(st.none() | simple_text, min_size=ndim, max_size=ndim)) # type: ignore[arg-type]