Skip to content

Commit 72e406d

Browse files
Apply ruff/refurb rule FURB188
FURB188 Prefer `removesuffix` over conditionally replacing with slice.
1 parent 2ef62cf commit 72e406d

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/zarr/storage/memory.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ async def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
156156

157157
async def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
158158
# docstring inherited
159-
if prefix.endswith("/"):
160-
prefix = prefix[:-1]
159+
prefix = prefix.removesuffix("/")
161160

162161
if prefix == "":
163162
keys_unique = {k.split("/")[0] for k in self._store_dict}

src/zarr/storage/zip.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,7 @@ async def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
245245

246246
async def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
247247
# docstring inherited
248-
if prefix.endswith("/"):
249-
prefix = prefix[:-1]
248+
prefix = prefix.removesuffix("/")
250249

251250
keys = self._zf.namelist()
252251
seen = set()

0 commit comments

Comments
 (0)