Skip to content

Commit 92d492b

Browse files
Apply ruff/flake8-simplify rule SIM105
SIM105 Use `contextlib.suppress(KeyError)` instead of `try`-`except`-`pass`
1 parent cf0355d commit 92d492b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/zarr/storage/memory.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import contextlib
34
from typing import TYPE_CHECKING, Self
45

56
from zarr.abc.store import ByteRangeRequest, Store
@@ -134,10 +135,8 @@ async def set_if_not_exists(self, key: str, value: Buffer) -> None:
134135
async def delete(self, key: str) -> None:
135136
# docstring inherited
136137
self._check_writable()
137-
try:
138+
with contextlib.suppress(KeyError):
138139
del self._store_dict[key]
139-
except KeyError:
140-
pass
141140

142141
async def set_partial_values(self, key_start_values: Iterable[tuple[str, int, bytes]]) -> None:
143142
# docstring inherited

0 commit comments

Comments
 (0)