Skip to content

Apply ruff preview rule #3131

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions src/zarr/core/metadata/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,10 @@ def parse_filters(data: object) -> tuple[numcodecs.abc.Codec, ...] | None:
"""
Parse a potential tuple of filters
"""
out: list[numcodecs.abc.Codec] = []

if data is None:
return data
if isinstance(data, Iterable):
out: list[numcodecs.abc.Codec] = []
for idx, val in enumerate(data):
if isinstance(val, numcodecs.abc.Codec):
out.append(val)
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async def store2(request: pytest.FixtureRequest, tmpdir: LEGACY_PATH) -> Store:
def sync_store(request: pytest.FixtureRequest, tmp_path: LEGACY_PATH) -> Store:
result = sync(parse_store(request.param, str(tmp_path)))
if not isinstance(result, Store):
raise TypeError("Wrong store class returned by test fixture! got " + result + " instead")
raise TypeError(f"Wrong store class returned by test fixture! got {result} instead")
return result


Expand Down
4 changes: 2 additions & 2 deletions tests/test_codec_entrypoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def set_path() -> Generator[None, None, None]:
@pytest.mark.usefixtures("set_path")
@pytest.mark.parametrize("codec_name", ["TestEntrypointCodec", "TestEntrypointGroup.Codec"])
def test_entrypoint_codec(codec_name: str) -> None:
config.set({"codecs.test": "package_with_entrypoint." + codec_name})
config.set({"codecs.test": f"package_with_entrypoint.{codec_name}"})
cls_test = zarr.registry.get_codec_class("test")
assert cls_test.__qualname__ == codec_name

Expand All @@ -42,7 +42,7 @@ def test_entrypoint_pipeline() -> None:
def test_entrypoint_buffer(buffer_name: str) -> None:
config.set(
{
"buffer": "package_with_entrypoint." + buffer_name,
"buffer": f"package_with_entrypoint.{buffer_name}",
"ndbuffer": "package_with_entrypoint.TestEntrypointNDBuffer",
}
)
Expand Down
6 changes: 4 additions & 2 deletions tests/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

pytest.importorskip("hypothesis")

from itertools import starmap

import hypothesis.extra.numpy as npst
import hypothesis.strategies as st
from hypothesis import assume, given, settings
Expand Down Expand Up @@ -60,7 +62,7 @@ def deep_equal(a: Any, b: Any) -> bool:
if isinstance(a, np.ndarray) and isinstance(b, np.ndarray):
if a.shape != b.shape:
return False
return all(deep_equal(x, y) for x, y in zip(a.flat, b.flat, strict=False))
return all(starmap(deep_equal, zip(a.flat, b.flat, strict=False)))

if isinstance(a, dict) and isinstance(b, dict):
if set(a.keys()) != set(b.keys()):
Expand All @@ -70,7 +72,7 @@ def deep_equal(a: Any, b: Any) -> bool:
if isinstance(a, (list, tuple)) and isinstance(b, (list, tuple)):
if len(a) != len(b):
return False
return all(deep_equal(x, y) for x, y in zip(a, b, strict=False))
return all(starmap(deep_equal, zip(a, b, strict=False)))

return a == b

Expand Down
Loading