Skip to content

Commit

Permalink
Enforce ruff/Perflint rules (PERF) (#2372)
Browse files Browse the repository at this point in the history
* Apply ruff/Perflint rule PERF401

PERF401 Use a list comprehension to create a transformed list

* Enforce ruff/Perflint rules (PERF)
  • Loading branch information
DimitriPapadopoulos authored Oct 17, 2024
1 parent e914c5c commit 85c9b5f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 27 deletions.
33 changes: 17 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -206,23 +206,24 @@ extend-exclude = [

[tool.ruff.lint]
extend-select = [
"ANN", # flake8-annotations
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"FLY", # flynt
"G", # flake8-logging-format
"I", # isort
"ISC", # flake8-implicit-str-concat
"PGH", # pygrep-hooks
"PT", # flake8-pytest-style
"PYI", # flake8-pyi
"RSE", # flake8-raise
"RET", # flake8-return
"ANN", # flake8-annotations
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"FLY", # flynt
"G", # flake8-logging-format
"I", # isort
"ISC", # flake8-implicit-str-concat
"PERF", # Perflint
"PGH", # pygrep-hooks
"PT", # flake8-pytest-style
"PYI", # flake8-pyi
"RSE", # flake8-raise
"RET", # flake8-return
"RUF",
"TCH", # flake8-type-checking
"TRY", # tryceratops
"UP", # pyupgrade
"W", # pycodestyle warnings
"TCH", # flake8-type-checking
"TRY", # tryceratops
"UP", # pyupgrade
"W", # pycodestyle warnings
]
ignore = [
"ANN101", # deprecated
Expand Down
8 changes: 1 addition & 7 deletions src/zarr/core/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -2873,13 +2873,7 @@ def chunks_initialized(
store_contents = list(
collect_aiterator(array.store_path.store.list_prefix(prefix=array.store_path.path))
)
out: list[str] = []

for chunk_key in array._iter_chunk_keys():
if chunk_key in store_contents:
out.append(chunk_key)

return tuple(out)
return tuple(chunk_key for chunk_key in array._iter_chunk_keys() if chunk_key in store_contents)


def _build_parents(
Expand Down
5 changes: 1 addition & 4 deletions src/zarr/core/metadata/v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ def validate_codecs(codecs: tuple[Codec, ...], dtype: DataType) -> None:
"""Check that the codecs are valid for the given dtype"""

# ensure that we have at least one ArrayBytesCodec
abcs: list[ArrayBytesCodec] = []
for codec in codecs:
if isinstance(codec, ArrayBytesCodec):
abcs.append(codec)
abcs: list[ArrayBytesCodec] = [codec for codec in codecs if isinstance(codec, ArrayBytesCodec)]
if len(abcs) == 0:
raise ValueError("At least one ArrayBytesCodec is required.")
elif len(abcs) > 1:
Expand Down

0 comments on commit 85c9b5f

Please sign in to comment.