diff --git a/src/zarr/core/indexing.py b/src/zarr/core/indexing.py index 1c153fc16..2cc70291d 100644 --- a/src/zarr/core/indexing.py +++ b/src/zarr/core/indexing.py @@ -218,9 +218,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: diff --git a/src/zarr/store/zip.py b/src/zarr/store/zip.py index 949660913..f9c458709 100644 --- a/src/zarr/store/zip.py +++ b/src/zarr/store/zip.py @@ -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}" diff --git a/src/zarr/testing/store.py b/src/zarr/testing/store.py index 7b78b8ed0..5c7500734 100644 --- a/src/zarr/testing/store.py +++ b/src/zarr/testing/store.py @@ -248,7 +248,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)) @@ -267,7 +267,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)