Skip to content

Commit c3728f3

Browse files
Apply ruff/Perflint rule PERF401
PERF401 Use a list comprehension to create a transformed list
1 parent 1131253 commit c3728f3

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