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

Apply assorted ruff/flake8-simplify rules (SIM) #2259

Merged
merged 2 commits into from
Sep 26, 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
4 changes: 1 addition & 3 deletions src/zarr/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ def is_scalar(value: Any, dtype: np.dtype[Any]) -> bool:
return True
if hasattr(value, "shape") and value.shape == ():
return True
if isinstance(value, tuple) and dtype.names and len(value) == len(dtype.names):
return True
return False
return isinstance(value, tuple) and dtype.names is not None and len(value) == len(dtype.names)


def is_pure_fancy_indexing(selection: Any, ndim: int) -> bool:
Expand Down
5 changes: 1 addition & 4 deletions src/zarr/store/zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,7 @@ async def clear(self) -> None:

async def empty(self) -> bool:
with self._lock:
if self._zf.namelist():
return False
else:
return True
return not self._zf.namelist()

def __str__(self) -> str:
return f"zip://{self.path}"
Expand Down
4 changes: 2 additions & 2 deletions src/zarr/testing/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ async def test_list_prefix(self, store: S) -> None:
for prefix in prefixes:
observed = tuple(sorted(await _collect_aiterator(store.list_prefix(prefix))))
expected: tuple[str, ...] = ()
for key in store_dict.keys():
for key in store_dict:
if key.startswith(prefix):
expected += (key.removeprefix(prefix),)
expected = tuple(sorted(expected))
Expand All @@ -245,7 +245,7 @@ async def test_list_dir(self, store: S) -> None:
await store._set_many(store_dict.items())

keys_observed = await _collect_aiterator(store.list_dir(root))
keys_expected = {k.removeprefix(root + "/").split("/")[0] for k in store_dict.keys()}
keys_expected = {k.removeprefix(root + "/").split("/")[0] for k in store_dict}

assert sorted(keys_observed) == sorted(keys_expected)

Expand Down