Skip to content

Commit 0cff15c

Browse files
Apply ruff/Perflint rule PERF401
PERF401 Use a list comprehension to create a transformed list
1 parent 840a3f7 commit 0cff15c

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

src/zarr/core/array.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,13 +2540,7 @@ def chunks_initialized(
25402540
store_contents = list(
25412541
collect_aiterator(array.store_path.store.list_prefix(prefix=array.store_path.path))
25422542
)
2543-
out: list[str] = []
2544-
2545-
for chunk_key in array._iter_chunk_keys():
2546-
if chunk_key in store_contents:
2547-
out.append(chunk_key)
2548-
2549-
return tuple(out)
2543+
return (chunk_key for chunk_key in array._iter_chunk_keys() if chunk_key in store_contents)
25502544

25512545

25522546
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)