Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce ruff/Perflint rules (PERF) #2372

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -207,23 +207,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 = [
"ANN003",
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