Skip to content

Commit 85c9b5f

Browse files
Enforce ruff/Perflint rules (PERF) (#2372)
* Apply ruff/Perflint rule PERF401 PERF401 Use a list comprehension to create a transformed list * Enforce ruff/Perflint rules (PERF)
1 parent e914c5c commit 85c9b5f

File tree

3 files changed

+19
-27
lines changed

3 files changed

+19
-27
lines changed

pyproject.toml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -206,23 +206,24 @@ extend-exclude = [
206206

207207
[tool.ruff.lint]
208208
extend-select = [
209-
"ANN", # flake8-annotations
210-
"B", # flake8-bugbear
211-
"C4", # flake8-comprehensions
212-
"FLY", # flynt
213-
"G", # flake8-logging-format
214-
"I", # isort
215-
"ISC", # flake8-implicit-str-concat
216-
"PGH", # pygrep-hooks
217-
"PT", # flake8-pytest-style
218-
"PYI", # flake8-pyi
219-
"RSE", # flake8-raise
220-
"RET", # flake8-return
209+
"ANN", # flake8-annotations
210+
"B", # flake8-bugbear
211+
"C4", # flake8-comprehensions
212+
"FLY", # flynt
213+
"G", # flake8-logging-format
214+
"I", # isort
215+
"ISC", # flake8-implicit-str-concat
216+
"PERF", # Perflint
217+
"PGH", # pygrep-hooks
218+
"PT", # flake8-pytest-style
219+
"PYI", # flake8-pyi
220+
"RSE", # flake8-raise
221+
"RET", # flake8-return
221222
"RUF",
222-
"TCH", # flake8-type-checking
223-
"TRY", # tryceratops
224-
"UP", # pyupgrade
225-
"W", # pycodestyle warnings
223+
"TCH", # flake8-type-checking
224+
"TRY", # tryceratops
225+
"UP", # pyupgrade
226+
"W", # pycodestyle warnings
226227
]
227228
ignore = [
228229
"ANN101", # deprecated

src/zarr/core/array.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2873,13 +2873,7 @@ def chunks_initialized(
28732873
store_contents = list(
28742874
collect_aiterator(array.store_path.store.list_prefix(prefix=array.store_path.path))
28752875
)
2876-
out: list[str] = []
2877-
2878-
for chunk_key in array._iter_chunk_keys():
2879-
if chunk_key in store_contents:
2880-
out.append(chunk_key)
2881-
2882-
return tuple(out)
2876+
return tuple(chunk_key for chunk_key in array._iter_chunk_keys() if chunk_key in store_contents)
28832877

28842878

28852879
def _build_parents(

src/zarr/core/metadata/v3.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ def validate_codecs(codecs: tuple[Codec, ...], dtype: DataType) -> None:
7777
"""Check that the codecs are valid for the given dtype"""
7878

7979
# ensure that we have at least one ArrayBytesCodec
80-
abcs: list[ArrayBytesCodec] = []
81-
for codec in codecs:
82-
if isinstance(codec, ArrayBytesCodec):
83-
abcs.append(codec)
80+
abcs: list[ArrayBytesCodec] = [codec for codec in codecs if isinstance(codec, ArrayBytesCodec)]
8481
if len(abcs) == 0:
8582
raise ValueError("At least one ArrayBytesCodec is required.")
8683
elif len(abcs) > 1:

0 commit comments

Comments
 (0)