6
6
from typing import TYPE_CHECKING , NamedTuple , Protocol , runtime_checkable
7
7
8
8
if TYPE_CHECKING :
9
- from collections .abc import AsyncGenerator , Iterable
9
+ from collections .abc import AsyncGenerator , AsyncIterator , Iterable
10
10
from types import TracebackType
11
11
from typing import Any , Self , TypeAlias
12
12
@@ -329,16 +329,19 @@ def supports_listing(self) -> bool:
329
329
...
330
330
331
331
@abstractmethod
332
- def list (self ) -> AsyncGenerator [str ]:
332
+ def list (self ) -> AsyncIterator [str ]:
333
333
"""Retrieve all keys in the store.
334
334
335
335
Returns
336
336
-------
337
- AsyncGenerator [str, None ]
337
+ AsyncIterator [str]
338
338
"""
339
+ # This method should be async, like overridden methods in child classes.
340
+ # However, that's not straightforward:
341
+ # https://stackoverflow.com/questions/68905848
339
342
340
343
@abstractmethod
341
- def list_prefix (self , prefix : str ) -> AsyncGenerator [str ]:
344
+ def list_prefix (self , prefix : str ) -> AsyncIterator [str ]:
342
345
"""
343
346
Retrieve all keys in the store that begin with a given prefix. Keys are returned relative
344
347
to the root of the store.
@@ -349,11 +352,14 @@ def list_prefix(self, prefix: str) -> AsyncGenerator[str]:
349
352
350
353
Returns
351
354
-------
352
- AsyncGenerator [str, None ]
355
+ AsyncIterator [str]
353
356
"""
357
+ # This method should be async, like overridden methods in child classes.
358
+ # However, that's not straightforward:
359
+ # https://stackoverflow.com/questions/68905848
354
360
355
361
@abstractmethod
356
- def list_dir (self , prefix : str ) -> AsyncGenerator [str ]:
362
+ def list_dir (self , prefix : str ) -> AsyncIterator [str ]:
357
363
"""
358
364
Retrieve all keys and prefixes with a given prefix and which do not contain the character
359
365
“/” after the given prefix.
@@ -364,8 +370,11 @@ def list_dir(self, prefix: str) -> AsyncGenerator[str]:
364
370
365
371
Returns
366
372
-------
367
- AsyncGenerator [str, None ]
373
+ AsyncIterator [str]
368
374
"""
375
+ # This method should be async, like overridden methods in child classes.
376
+ # However, that's not straightforward:
377
+ # https://stackoverflow.com/questions/68905848
369
378
370
379
async def delete_dir (self , prefix : str ) -> None :
371
380
"""
0 commit comments