Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/apify_client/_resource_clients/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from apify_client._utils.http import response_to_dict, response_to_list

if TYPE_CHECKING:
from collections.abc import AsyncIterator, Iterator
from collections.abc import AsyncGenerator, AsyncIterator, Generator, Iterator
from datetime import timedelta

from apify_client._literals import GeneralAccess
Expand Down Expand Up @@ -405,7 +405,7 @@ def stream_items(
flatten: list[str] | None = None,
signature: str | None = None,
timeout: Timeout = 'long',
) -> Iterator[HttpResponse]:
) -> Generator[HttpResponse]:
"""Retrieve the items in the dataset as a stream.

https://docs.apify.com/api/v2#/reference/datasets/item-collection/get-items
Expand Down Expand Up @@ -970,7 +970,7 @@ async def stream_items(
flatten: list[str] | None = None,
signature: str | None = None,
timeout: Timeout = 'long',
) -> AsyncIterator[HttpResponse]:
) -> AsyncGenerator[HttpResponse]:
"""Retrieve the items in the dataset as a stream.

https://docs.apify.com/api/v2#/reference/datasets/item-collection/get-items
Expand Down
6 changes: 3 additions & 3 deletions src/apify_client/_resource_clients/key_value_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from apify_client.errors import ApifyApiError, InvalidResponseBodyError

if TYPE_CHECKING:
from collections.abc import AsyncIterator, Iterator
from collections.abc import AsyncGenerator, AsyncIterator, Generator, Iterator
from datetime import timedelta

from apify_client._literals import GeneralAccess
Expand Down Expand Up @@ -318,7 +318,7 @@ def get_record_as_bytes(self, key: str, *, signature: str | None = None, timeout
@contextmanager
def stream_record(
self, key: str, *, signature: str | None = None, timeout: Timeout = 'long'
) -> Iterator[dict | None]:
) -> Generator[dict | None]:
"""Retrieve the given record from the key-value store, as a stream.

https://docs.apify.com/api/v2#/reference/key-value-stores/record/get-record
Expand Down Expand Up @@ -756,7 +756,7 @@ async def get_record_as_bytes(
@asynccontextmanager
async def stream_record(
self, key: str, *, signature: str | None = None, timeout: Timeout = 'long'
) -> AsyncIterator[dict | None]:
) -> AsyncGenerator[dict | None]:
"""Retrieve the given record from the key-value store, as a stream.

https://docs.apify.com/api/v2#/reference/key-value-stores/record/get-record
Expand Down
6 changes: 3 additions & 3 deletions src/apify_client/_resource_clients/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from apify_client.errors import ApifyApiError

if TYPE_CHECKING:
from collections.abc import AsyncIterator, Iterator
from collections.abc import AsyncGenerator, Generator

from apify_client.http_clients import HttpResponse
from apify_client.types import Timeout
Expand Down Expand Up @@ -96,7 +96,7 @@ def get_as_bytes(self, *, raw: bool = False, timeout: Timeout = 'long') -> bytes
return None

@contextmanager
def stream(self, *, raw: bool = False, timeout: Timeout = 'long') -> Iterator[HttpResponse | None]:
def stream(self, *, raw: bool = False, timeout: Timeout = 'long') -> Generator[HttpResponse | None]:
"""Retrieve the log as a stream.

https://docs.apify.com/api/v2#/reference/logs/log/get-log
Expand Down Expand Up @@ -211,7 +211,7 @@ async def get_as_bytes(self, *, raw: bool = False, timeout: Timeout = 'long') ->
return None

@asynccontextmanager
async def stream(self, *, raw: bool = False, timeout: Timeout = 'long') -> AsyncIterator[HttpResponse | None]:
async def stream(self, *, raw: bool = False, timeout: Timeout = 'long') -> AsyncGenerator[HttpResponse | None]:
"""Retrieve the log as a stream.

https://docs.apify.com/api/v2#/reference/logs/log/get-log
Expand Down
4 changes: 2 additions & 2 deletions src/apify_client/_utils/try_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from collections.abc import Iterator
from collections.abc import Generator
from typing import Any


Expand All @@ -19,7 +19,7 @@ class ImportState:


@contextmanager
def try_import(module_name: str, *symbol_names: str, dependency_name: str, extra_name: str) -> Iterator[ImportState]:
def try_import(module_name: str, *symbol_names: str, dependency_name: str, extra_name: str) -> Generator[ImportState]:
"""Context manager to attempt importing symbols into a module.

If the named optional dependency is missing, the symbols are replaced with `FailedImport` objects whose message
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_http_compressors.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from apify_client.http_compressors._resolve import resolve_compressor

if TYPE_CHECKING:
from collections.abc import Callable, Iterator
from collections.abc import Callable, Generator

from pytest_httpserver import HTTPServer

Expand All @@ -29,7 +29,7 @@


@contextmanager
def _brotli_unavailable() -> Iterator[None]:
def _brotli_unavailable() -> Generator[None]:
"""Reimport the `http_compressors` package with the `brotli` import forced to fail.

Simulates an environment where the optional `brotli` extra is not installed, and restores the
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from apify_client._streamed_log import StreamedLog, StreamedLogAsync, StreamedLogBase

if TYPE_CHECKING:
from collections.abc import AsyncIterator, Callable, Iterator
from collections.abc import AsyncGenerator, AsyncIterator, Callable, Iterator

from _pytest.logging import LogCaptureFixture
from pytest_httpserver import HTTPServer
Expand Down Expand Up @@ -1557,7 +1557,7 @@ async def test_streamed_log_async_stop_reads_log_when_it_lands_while_stream_reop
reopening = asyncio.Event()

@asynccontextmanager
async def never_opening_stream() -> AsyncIterator[None]:
async def never_opening_stream() -> AsyncGenerator[None]:
reopening.set()
await asyncio.Event().wait()
yield
Expand Down
Loading
Loading