Skip to content

Commit 5209fac

Browse files
Fix the return type of Store list methods
`None` was added in 0e035fb, let's try to remove it.
1 parent 00c4502 commit 5209fac

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

src/zarr/abc/store.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ def supports_listing(self) -> bool:
330330
...
331331

332332
@abstractmethod
333-
async def list(self) -> AsyncGenerator[str, None]:
333+
async def list(self) -> AsyncGenerator[str]:
334334
"""Retrieve all keys in the store.
335335
336336
Returns
@@ -340,7 +340,7 @@ async def list(self) -> AsyncGenerator[str, None]:
340340
yield ""
341341

342342
@abstractmethod
343-
async def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
343+
async def list_prefix(self, prefix: str) -> AsyncGenerator[str]:
344344
"""
345345
Retrieve all keys in the store that begin with a given prefix. Keys are returned with the
346346
common leading prefix removed.
@@ -356,7 +356,7 @@ async def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
356356
yield ""
357357

358358
@abstractmethod
359-
async def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
359+
async def list_dir(self, prefix: str) -> AsyncGenerator[str]:
360360
"""
361361
Retrieve all keys and prefixes with a given prefix and which do not contain the character
362362
“/” after the given prefix.

src/zarr/storage/local.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,14 @@ async def exists(self, key: str) -> bool:
217217
path = self.root / key
218218
return await asyncio.to_thread(path.is_file)
219219

220-
async def list(self) -> AsyncGenerator[str, None]:
220+
async def list(self) -> AsyncGenerator[str]:
221221
# docstring inherited
222222
to_strip = self.root.as_posix() + "/"
223223
for p in list(self.root.rglob("*")):
224224
if p.is_file():
225225
yield p.as_posix().replace(to_strip, "")
226226

227-
async def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
227+
async def list_prefix(self, prefix: str) -> AsyncGenerator[str]:
228228
# docstring inherited
229229
to_strip = (
230230
(self.root / prefix).as_posix() + "/"
@@ -233,7 +233,7 @@ async def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
233233
if p.is_file():
234234
yield p.as_posix().replace(to_strip, "")
235235

236-
async def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
236+
async def list_dir(self, prefix: str) -> AsyncGenerator[str]:
237237
# docstring inherited
238238
base = self.root / prefix
239239
to_strip = str(base) + "/"

src/zarr/storage/logging.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,19 +204,19 @@ async def set_partial_values(
204204
with self.log(keys):
205205
return await self._store.set_partial_values(key_start_values=key_start_values)
206206

207-
async def list(self) -> AsyncGenerator[str, None]:
207+
async def list(self) -> AsyncGenerator[str]:
208208
# docstring inherited
209209
with self.log():
210210
async for key in self._store.list():
211211
yield key
212212

213-
async def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
213+
async def list_prefix(self, prefix: str) -> AsyncGenerator[str]:
214214
# docstring inherited
215215
with self.log(prefix):
216216
async for key in self._store.list_prefix(prefix=prefix):
217217
yield key
218218

219-
async def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
219+
async def list_dir(self, prefix: str) -> AsyncGenerator[str]:
220220
# docstring inherited
221221
with self.log(prefix):
222222
async for key in self._store.list_dir(prefix=prefix):

src/zarr/storage/memory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,18 @@ async def set_partial_values(self, key_start_values: Iterable[tuple[str, int, by
143143
# docstring inherited
144144
raise NotImplementedError
145145

146-
async def list(self) -> AsyncGenerator[str, None]:
146+
async def list(self) -> AsyncGenerator[str]:
147147
# docstring inherited
148148
for key in self._store_dict:
149149
yield key
150150

151-
async def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
151+
async def list_prefix(self, prefix: str) -> AsyncGenerator[str]:
152152
# docstring inherited
153153
for key in self._store_dict:
154154
if key.startswith(prefix):
155155
yield key.removeprefix(prefix)
156156

157-
async def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
157+
async def list_dir(self, prefix: str) -> AsyncGenerator[str]:
158158
# docstring inherited
159159
prefix = prefix.rstrip("/")
160160

src/zarr/storage/remote.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,13 @@ async def set_partial_values(
322322
# docstring inherited
323323
raise NotImplementedError
324324

325-
async def list(self) -> AsyncGenerator[str, None]:
325+
async def list(self) -> AsyncGenerator[str]:
326326
# docstring inherited
327327
allfiles = await self.fs._find(self.path, detail=False, withdirs=False)
328328
for onefile in (a.replace(self.path + "/", "") for a in allfiles):
329329
yield onefile
330330

331-
async def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
331+
async def list_dir(self, prefix: str) -> AsyncGenerator[str]:
332332
# docstring inherited
333333
prefix = f"{self.path}/{prefix.rstrip('/')}"
334334
try:
@@ -338,7 +338,7 @@ async def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
338338
for onefile in (a.replace(prefix + "/", "") for a in allfiles):
339339
yield onefile.removeprefix(self.path).removeprefix("/")
340340

341-
async def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
341+
async def list_prefix(self, prefix: str) -> AsyncGenerator[str]:
342342
# docstring inherited
343343
find_str = f"{self.path}/{prefix}"
344344
for onefile in await self.fs._find(find_str, detail=False, maxdepth=None, withdirs=False):

src/zarr/storage/zip.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,19 +234,19 @@ async def exists(self, key: str) -> bool:
234234
else:
235235
return True
236236

237-
async def list(self) -> AsyncGenerator[str, None]:
237+
async def list(self) -> AsyncGenerator[str]:
238238
# docstring inherited
239239
with self._lock:
240240
for key in self._zf.namelist():
241241
yield key
242242

243-
async def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
243+
async def list_prefix(self, prefix: str) -> AsyncGenerator[str]:
244244
# docstring inherited
245245
async for key in self.list():
246246
if key.startswith(prefix):
247247
yield key.removeprefix(prefix)
248248

249-
async def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
249+
async def list_dir(self, prefix: str) -> AsyncGenerator[str]:
250250
# docstring inherited
251251
prefix = prefix.rstrip("/")
252252

0 commit comments

Comments
 (0)