Skip to content

Commit a968b1b

Browse files
authored
fix: Fix BaseDatasetClient.iter_items type hints (#680)
Using syntax recommended in mypy docs: https://mypy.readthedocs.io/en/stable/more_types.html#asynchronous-iterators
1 parent f74a02e commit a968b1b

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/crawlee/base_storage_client/_base_dataset_client.py

+5
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ async def iterate_items(
122122
An asynchronous iterator of dictionary objects, each representing a dataset item after applying
123123
the specified filters and transformations.
124124
"""
125+
# This syntax is to make mypy properly work with abstract AsyncIterator.
126+
# https://mypy.readthedocs.io/en/stable/more_types.html#asynchronous-iterators
127+
raise NotImplementedError
128+
if False: # type: ignore[unreachable]
129+
yield 0
125130

126131
@abstractmethod
127132
async def get_items_as_bytes(

src/crawlee/memory_storage_client/_dataset_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ async def list_items(
203203
)
204204

205205
@override
206-
async def iterate_items( # type: ignore
206+
async def iterate_items(
207207
self,
208208
*,
209209
offset: int = 0,

src/crawlee/storages/_dataset.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ async def iterate_items(
402402
Yields:
403403
Each item from the dataset as a dictionary.
404404
"""
405-
async for item in self._resource_client.iterate_items( # type: ignore
405+
async for item in self._resource_client.iterate_items(
406406
offset=offset,
407407
limit=limit,
408408
clean=clean,

0 commit comments

Comments
 (0)