Skip to content

Commit 52ecff8

Browse files
committed
resolve
2 parents 7714450 + 1df6792 commit 52ecff8

32 files changed

+325
-356
lines changed

.github/workflows/_async_docstrings_check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
steps:
1515
- name: Checkout repository
16-
uses: actions/checkout@v4
16+
uses: actions/checkout@v5
1717

1818
- name: Set up Python
1919
uses: actions/setup-python@v5

.github/workflows/build_and_deploy_docs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222

2323
steps:
2424
- name: Checkout repository
25-
uses: actions/checkout@v4
25+
uses: actions/checkout@v5
2626
with:
2727
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
2828

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ All notable changes to this project will be documented in this file.
99

1010
- Extend status parameter to an array of possible statuses ([#455](https://github.com/apify/apify-client-python/pull/455)) ([76f6769](https://github.com/apify/apify-client-python/commit/76f676973d067ce8af398d8e6ceea55595da5ecf)) by [@JanHranicky](https://github.com/JanHranicky)
1111

12+
### Refactor
13+
14+
- [**breaking**] Remove support for passing a single string to the `unwind` parameter in `DatasetClient` ([#467](https://github.com/apify/apify-client-python/pull/467)) ([e8aea2c](https://github.com/apify/apify-client-python/commit/e8aea2c8f3833082bf78562f3fa981a1f8e88b26)) by [@Mantisus](https://github.com/Mantisus), closes [#255](https://github.com/apify/apify-client-python/issues/255)
15+
1216

1317
<!-- git-cliff-unreleased-end -->
1418
## [1.12.2](https://github.com/apify/apify-client-python/releases/tag/v1.12.2) (2025-08-08)

docs/02_concepts/09_streaming.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Supported streaming methods:
1818
- [`KeyValueStoreClient.stream_record`](/reference/class/KeyValueStoreClient#stream_record) - Stream key-value store records as raw data.
1919
- [`LogClient.stream`](/reference/class/LogClient#stream) - Stream logs in real time.
2020

21-
These methods return a raw, context-managed `httpx.Response` object. The response must be consumed within a with block to ensure that the connection is closed automatically, preventing memory leaks or unclosed connections.
21+
These methods return a raw, context-managed `impit.Response` object. The response must be consumed within a with block to ensure that the connection is closed automatically, preventing memory leaks or unclosed connections.
2222

2323
The following example demonstrates how to stream the logs of an Actor run incrementally:
2424

docs/02_concepts/code/01_async_support.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ async def main() -> None:
1717
# Stream the logs
1818
async with log_client.stream() as async_log_stream:
1919
if async_log_stream:
20-
async for line in async_log_stream.aiter_lines():
21-
print(line)
20+
async for bytes_chunk in async_log_stream.aiter_bytes():
21+
print(bytes_chunk)
2222

2323

2424
if __name__ == '__main__':

docs/02_concepts/code/09_streaming_async.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ async def main() -> None:
1010

1111
async with log_client.stream() as log_stream:
1212
if log_stream:
13-
for line in log_stream.iter_lines():
14-
print(line)
13+
async for bytes_chunk in log_stream.aiter_bytes():
14+
print(bytes_chunk)

docs/02_concepts/code/09_streaming_sync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ def main() -> None:
1010

1111
with log_client.stream() as log_stream:
1212
if log_stream:
13-
for line in log_stream.iter_lines():
14-
print(line)
13+
for bytes_chunk in log_stream.iter_bytes():
14+
print(bytes_chunk)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
id: upgrading-to-v2
3+
title: Upgrading to v2
4+
---
5+
6+
This page summarizes the breaking changes between Apify Python API client v1.x and v2.0.
7+
8+
## Python version support
9+
10+
<!-- TODO -->
11+
12+
## Change underlying HTTP library
13+
14+
In v2.0, the Apify Python API client switched from using `httpx` to [`impit`](https://github.com/apify/impit) as the underlying HTTP library.
15+
16+
## Update signature of methods
17+
18+
<!-- TODO -->

pyproject.toml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ keywords = ["apify", "api", "client", "automation", "crawling", "scraping"]
2727
dependencies = [
2828
"apify-shared<2.0.0",
2929
"colorama>=0.4.0",
30-
"httpx>=0.25",
30+
"impit>=0.5.2",
3131
"more_itertools>=10.0.0",
3232
]
3333

@@ -42,23 +42,22 @@ dependencies = [
4242

4343
[dependency-groups]
4444
dev = [
45-
"dycw-pytest-only>=2.1.1",
45+
"dycw-pytest-only~=2.1.0",
4646
"griffe~=1.11.0",
4747
"mypy~=1.17.0",
4848
"pre-commit~=4.3.0",
4949
"pydoc-markdown~=4.8.0",
5050
"pytest-asyncio~=1.1.0",
5151
"pytest-cov~=6.2.0",
52-
"pytest-timeout>=2.4.0",
52+
"pytest-timeout~=2.4.0",
5353
"pytest-xdist~=3.8.0",
5454
"pytest~=8.4.0",
55-
"pytest-httpserver>=1.1.3",
55+
"pytest-httpserver~=1.1.0",
5656
"redbaron~=0.9.0",
57-
"respx~=0.22.0",
5857
"ruff~=0.12.0",
5958
"setuptools", # setuptools are used by pytest but not explicitly required
6059
"types-colorama~=0.4.15.20240106",
61-
"werkzeug~=3.0.0", # Werkzeug is used by pytest-httpserver
60+
"werkzeug~=3.1.0", # Werkzeug is used by pytest-httpserver
6261
]
6362

6463
[tool.hatch.build.targets.wheel]
@@ -175,7 +174,7 @@ warn_unused_ignores = true
175174
exclude = []
176175

177176
[[tool.mypy.overrides]]
178-
module = ["pandas", "respx"]
177+
module = ["pandas"]
179178
ignore_missing_imports = true
180179

181180
[tool.basedpyright]

src/apify_client/_errors.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from __future__ import annotations
22

3-
import httpx
3+
import json as jsonlib
4+
5+
import impit
46
from apify_shared.utils import ignore_docs
57

68

@@ -17,20 +19,21 @@ class ApifyApiError(ApifyClientError):
1719
"""
1820

1921
@ignore_docs
20-
def __init__(self, response: httpx.Response, attempt: int) -> None:
22+
def __init__(self, response: impit.Response, attempt: int, method: str = 'GET') -> None:
2123
"""Initialize a new instance.
2224
2325
Args:
2426
response: The response to the failed API call.
2527
attempt: Which attempt was the request that failed.
28+
method: The HTTP method used for the request.
2629
"""
2730
self.message: str | None = None
2831
self.type: str | None = None
2932
self.data = dict[str, str]()
3033

3134
self.message = f'Unexpected error: {response.text}'
3235
try:
33-
response_data = response.json()
36+
response_data = jsonlib.loads(response.text)
3437
if 'error' in response_data:
3538
self.message = response_data['error']['message']
3639
self.type = response_data['error']['type']
@@ -44,7 +47,7 @@ def __init__(self, response: httpx.Response, attempt: int) -> None:
4447
self.name = 'ApifyApiError'
4548
self.status_code = response.status_code
4649
self.attempt = attempt
47-
self.http_method = response.request.method
50+
self.http_method = method
4851

4952
# TODO: self.client_method # noqa: TD003
5053
# TODO: self.original_stack # noqa: TD003
@@ -61,7 +64,7 @@ class InvalidResponseBodyError(ApifyClientError):
6164
"""
6265

6366
@ignore_docs
64-
def __init__(self, response: httpx.Response) -> None:
67+
def __init__(self, response: impit.Response) -> None:
6568
"""Initialize a new instance.
6669
6770
Args:
@@ -80,8 +83,8 @@ def is_retryable_error(exc: Exception) -> bool:
8083
exc,
8184
(
8285
InvalidResponseBodyError,
83-
httpx.NetworkError,
84-
httpx.TimeoutException,
85-
httpx.RemoteProtocolError,
86+
impit.NetworkError,
87+
impit.TimeoutException,
88+
impit.RemoteProtocolError,
8689
),
8790
)

0 commit comments

Comments
 (0)