diff --git a/src/crawlee/storage_clients/_base/_dataset_client.py b/src/crawlee/storage_clients/_base/_dataset_client.py index e1a3c4b468..bd13144e52 100644 --- a/src/crawlee/storage_clients/_base/_dataset_client.py +++ b/src/crawlee/storage_clients/_base/_dataset_client.py @@ -1,10 +1,11 @@ from __future__ import annotations from abc import ABC, abstractmethod +from collections.abc import Sequence from typing import TYPE_CHECKING if TYPE_CHECKING: - from collections.abc import AsyncIterator, Mapping, Sequence + from collections.abc import AsyncIterator, Mapping from crawlee._types import JsonSerializable from crawlee.storage_clients.models import DatasetItemsListPage, DatasetMetadata @@ -91,3 +92,16 @@ async def iterate_items( raise NotImplementedError if False: yield {} + + @staticmethod + def _is_sequence_of_items( + data: Sequence[Mapping[str, JsonSerializable]] | Mapping[str, JsonSerializable], + ) -> bool: + """Tell whether the `push_data` payload is a sequence of items rather than a single item. + + No `push_data` implementation in this repository uses this helper - it is inlined there instead. It stays + on the base class because the Apify SDK up to 4.0.1 calls it from `ApifyDatasetClient.push_data`, so + removing it breaks every Actor that resolves such an SDK version against this package. Drop it in the + next major version, once those SDK versions are out of the supported range. + """ + return isinstance(data, Sequence)