Skip to content

Commit 9847555

Browse files
Apply ruff/flake8-simplify rule SIM118
SIM118 Use `key in dict` instead of `key in dict.keys()`
1 parent 8fc5bde commit 9847555

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/zarr/core/group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,7 @@ def _members_consolidated(
12251225

12261226
# we kind of just want the top-level keys.
12271227
if consolidated_metadata is not None:
1228-
for key in consolidated_metadata.metadata.keys():
1228+
for key in consolidated_metadata.metadata:
12291229
obj = self._getitem_consolidated(
12301230
self.store_path, key, prefix=self.name
12311231
) # Metadata -> Group/Array

tests/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def test_save(store: Store, n_args: int, n_kwargs: int) -> None:
154154
assert isinstance(group, Group)
155155
for array in group.array_values():
156156
assert_array_equal(array[:], data)
157-
for k in kwargs.keys():
157+
for k in kwargs:
158158
assert k in group
159159
assert group.nmembers() == n_args + n_kwargs
160160

tests/test_indexing.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,7 +1806,10 @@ async def test_accessed_chunks(
18061806
# counts are consistent that this might have happened
18071807
if optype == "__setitem__":
18081808
assert ("__getitem__", ci) not in delta_counts or delta_counts.pop(
1809-
("__getitem__", ci)
1809+
(
1810+
"__getitem__",
1811+
ci,
1812+
)
18101813
) == 1
18111814
# Check that no other chunks were accessed
18121815
assert len(delta_counts) == 0
@@ -1893,7 +1896,10 @@ def test_iter_grid(
18931896

18941897
# generate a numpy array of indices, and index it
18951898
coord_array = np.array(list(itertools.product(*[range(s) for s in grid_shape]))).reshape(
1896-
(*grid_shape, ndim)
1899+
(
1900+
*grid_shape,
1901+
ndim,
1902+
)
18971903
)
18981904
coord_array_indexed = coord_array[
18991905
tuple(slice(o, o + s, 1) for o, s in zip(origin, selection_shape, strict=False))

0 commit comments

Comments
 (0)