|
8 | 8 | from zarr.storage.common import _dereference_path |
9 | 9 |
|
10 | 10 | if TYPE_CHECKING: |
11 | | - from collections.abc import AsyncGenerator, Iterable |
| 11 | + from collections.abc import AsyncIterator, Iterable |
12 | 12 |
|
13 | 13 | from fsspec.asyn import AsyncFileSystem |
14 | 14 |
|
@@ -280,24 +280,25 @@ async def set_partial_values( |
280 | 280 | # docstring inherited |
281 | 281 | raise NotImplementedError |
282 | 282 |
|
283 | | - async def list(self) -> AsyncGenerator[str]: |
| 283 | + async def list(self) -> AsyncIterator[str]: |
284 | 284 | # docstring inherited |
285 | 285 | allfiles = await self.fs._find(self.path, detail=False, withdirs=False) |
286 | | - for onefile in (a.replace(self.path + "/", "") for a in allfiles): |
287 | | - yield onefile |
| 286 | + return (onefile for onefile in (a.replace(self.path + "/", "") for a in allfiles)) |
288 | 287 |
|
289 | | - async def list_dir(self, prefix: str) -> AsyncGenerator[str]: |
| 288 | + async def list_dir(self, prefix: str) -> AsyncIterator[str]: |
290 | 289 | # docstring inherited |
291 | 290 | prefix = f"{self.path}/{prefix.rstrip('/')}" |
292 | 291 | try: |
293 | 292 | allfiles = await self.fs._ls(prefix, detail=False) |
294 | 293 | except FileNotFoundError: |
295 | | - return |
296 | | - for onefile in (a.replace(prefix + "/", "") for a in allfiles): |
297 | | - yield onefile.removeprefix(self.path).removeprefix("/") |
| 294 | + return iter([]) |
| 295 | + return ( |
| 296 | + onefile.removeprefix(self.path).removeprefix("/") |
| 297 | + for onefile in (a.replace(prefix + "/", "") for a in allfiles) |
| 298 | + ) |
298 | 299 |
|
299 | | - async def list_prefix(self, prefix: str) -> AsyncGenerator[str]: |
| 300 | + async def list_prefix(self, prefix: str) -> AsyncIterator[str]: |
300 | 301 | # docstring inherited |
301 | 302 | find_str = f"{self.path}/{prefix}" |
302 | | - for onefile in await self.fs._find(find_str, detail=False, maxdepth=None, withdirs=False): |
303 | | - yield onefile.removeprefix(find_str) |
| 303 | + allfiles = await self.fs._find(find_str, detail=False, maxdepth=None, withdirs=False) |
| 304 | + return (onefile.removeprefix(find_str) for onefile in allfiles) |
0 commit comments