Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
- simplify code comments
- use `removeprefix` instead of `strip`
  • Loading branch information
d-v-b authored Apr 19, 2024
1 parent ccb2dfe commit 4ea442d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/zarr/v3/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,11 @@ async def members(self) -> AsyncGenerator[tuple[str, AsyncArray | AsyncGroup], N
try:
# TODO: performance optimization -- load children concurrently
child = await self.getitem(key)
# keyerror is raised when `key``names an object in the store
# in which case `subkey` cannot be the name of a sub-array or sub-group.
yield key, child
except KeyError:
# keyerror is raised when `subkey` names an object (in the object storage sense),
# as opposed to a prefix, in the store under the prefix associated with this group
# in which case `subkey` cannot be the name of a sub-array or sub-group.
# keyerror is raised when `key` names an object (in the object storage sense),
# as opposed to a prefix, in the store under the prefix associated with this group.
# In this case, `key` cannot be the name of a sub-array or sub-group.
logger.warning(
"Object at %s is not recognized as a component of a Zarr hierarchy.", key
)
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/v3/store/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ async def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
async def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
for key in self._store_dict:
if key.startswith(prefix + "/") and key != prefix:
yield key.strip(prefix + "/").rsplit("/", maxsplit=1)[0]
yield key.removeprefix(prefix + "/").rsplit("/", maxsplit=1)[0]

0 comments on commit 4ea442d

Please sign in to comment.