Skip to content

Commit 4010b32

Browse files
Consistent signatures for listdir() and rmdir()
1 parent f0677c2 commit 4010b32

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

zarr/_storage/store.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ class Store(BaseStore):
118118
119119
"""
120120

121-
def listdir(self, path: str = "") -> List[str]:
121+
def listdir(self, path: Path = None) -> List[str]:
122122
path = normalize_storage_path(path)
123123
return _listdir_from_keys(self, path)
124124

125-
def rmdir(self, path: str = "") -> None:
125+
def rmdir(self, path: Path = None) -> None:
126126
if not self.is_erasable():
127127
raise NotImplementedError(
128128
f'{type(self)} is not erasable, cannot call "rmdir"'
@@ -150,15 +150,7 @@ def _rename_from_keys(store: BaseStore, src_path: str, dst_path: str) -> None:
150150
store[new_key] = store.pop(key)
151151

152152

153-
def _rmdir_from_keys(store: Union[BaseStore, MutableMapping], path: Optional[str] = None) -> None:
154-
# assume path already normalized
155-
prefix = _path_to_prefix(path)
156-
for key in list(store.keys()):
157-
if key.startswith(prefix):
158-
del store[key]
159-
160-
161-
def _listdir_from_keys(store: BaseStore, path: Optional[str] = None) -> List[str]:
153+
def _listdir_from_keys(store: BaseStore, path: Optional[Path] = None) -> List[str]:
162154
# assume path already normalized
163155
prefix = _path_to_prefix(path)
164156
children = set()
@@ -168,3 +160,11 @@ def _listdir_from_keys(store: BaseStore, path: Optional[str] = None) -> List[str
168160
child = suffix.split('/')[0]
169161
children.add(child)
170162
return sorted(children)
163+
164+
165+
def _rmdir_from_keys(store: Union[BaseStore, MutableMapping], path: Optional[Path] = None) -> None:
166+
# assume path already normalized
167+
prefix = _path_to_prefix(path)
168+
for key in list(store.keys()):
169+
if key.startswith(prefix):
170+
del store[key]

zarr/storage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,7 +2157,7 @@ def _keys(self):
21572157
self._keys_cache = list(self._store.keys())
21582158
return self._keys_cache
21592159

2160-
def listdir(self, path: Path = None):
2160+
def listdir(self, path: Path = None) -> List[str]:
21612161
with self._mutex:
21622162
try:
21632163
return self._listdir_cache[path]
@@ -2682,5 +2682,5 @@ def __setitem__(self, key, value):
26822682
def getsize(self, path):
26832683
return getsize(self.meta_store, path)
26842684

2685-
def listdir(self, path):
2685+
def listdir(self, path=None):
26862686
return listdir(self.meta_store, path)

0 commit comments

Comments
 (0)