Skip to content

Commit 4a2a997

Browse files
committed
Merge remote-tracking branch 'origin/master' into worktree-fix-flaky-1
2 parents 58e5a7c + ac95e35 commit 4a2a997

24 files changed

Lines changed: 5912 additions & 5843 deletions

‎.github/workflows/_checks.yaml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
uses: actions/checkout@v7
5959

6060
- name: Set up Python
61-
uses: actions/setup-python@v6
61+
uses: actions/setup-python@v7
6262
with:
6363
python-version: ${{ env.PYTHON_VERSION }}
6464

@@ -81,7 +81,7 @@ jobs:
8181
uses: actions/checkout@v7
8282

8383
- name: Set up Node
84-
uses: actions/setup-node@v6
84+
uses: actions/setup-node@v7
8585
with:
8686
node-version: ${{ env.NODE_VERSION }}
8787

@@ -102,7 +102,7 @@ jobs:
102102
uses: actions/checkout@v7
103103

104104
- name: Set up Node
105-
uses: actions/setup-node@v6
105+
uses: actions/setup-node@v7
106106
with:
107107
node-version: ${{ env.NODE_VERSION }}
108108

@@ -194,7 +194,7 @@ jobs:
194194
uses: actions/checkout@v7
195195

196196
- name: Set up Python ${{ matrix.python-version }}
197-
uses: actions/setup-python@v6
197+
uses: actions/setup-python@v7
198198
with:
199199
python-version: ${{ matrix.python-version }}
200200

‎.github/workflows/manual_release_docs.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ jobs:
5555
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
5656

5757
- name: Set up Node
58-
uses: actions/setup-node@v6
58+
uses: actions/setup-node@v7
5959
with:
6060
node-version: ${{ env.NODE_VERSION }}
6161

6262
- name: Set up Python
63-
uses: actions/setup-python@v6
63+
uses: actions/setup-python@v7
6464
with:
6565
python-version: ${{ env.PYTHON_VERSION }}
6666

‎.github/workflows/manual_version_docs.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ jobs:
5454
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
5555

5656
- name: Set up Node
57-
uses: actions/setup-node@v6
57+
uses: actions/setup-node@v7
5858
with:
5959
node-version: ${{ env.NODE_VERSION }}
6060

6161
- name: Set up Python
62-
uses: actions/setup-python@v6
62+
uses: actions/setup-python@v7
6363
with:
6464
python-version: ${{ env.PYTHON_VERSION }}
6565

‎CHANGELOG.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
<!-- git-cliff-unreleased-start -->
6-
## 3.1.1 - **not yet released**
5+
## [3.1.1](https://github.com/apify/apify-client-python/releases/tag/v3.1.1) (2026-08-03)
76

87
### 🐛 Bug Fixes
98

109
- Add missing cannot-monetize-without-payout-billing-info error code ([#960](https://github.com/apify/apify-client-python/pull/960)) ([c1bffc6](https://github.com/apify/apify-client-python/commit/c1bffc6e9f67a8358769591006f46bb2831594d8)) by [@apify-service-account](https://github.com/apify-service-account)
10+
- Normalize query params in dataset create_items_public_url ([#963](https://github.com/apify/apify-client-python/pull/963)) ([c3ecaa9](https://github.com/apify/apify-client-python/commit/c3ecaa96a43415d70d71c27e7dd177e9992c84e4)) by [@vdusek](https://github.com/vdusek)
11+
- Keep pagination iterators advancing past fully-filtered pages ([#964](https://github.com/apify/apify-client-python/pull/964)) ([2e7f75c](https://github.com/apify/apify-client-python/commit/2e7f75ca951f2b7b59c319badd6e024d47fe67f1)) by [@vdusek](https://github.com/vdusek)
1112

1213

13-
<!-- git-cliff-unreleased-end -->
1414
## [3.1.0](https://github.com/apify/apify-client-python/releases/tag/v3.1.0) (2026-07-20)
1515

1616
### 🚀 Features

‎docs/01_introduction/index.mdx‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,11 @@ For better request-body compression, opt in to `brotli`, which compresses better
5656
</TabItem>
5757
<TabItem value="conda-forge" label="conda-forge">
5858
```bash
59-
conda install conda-forge::apify-client conda-forge::brotli-python
59+
conda install conda-forge::apify-client
6060
```
6161
</TabItem>
6262
</Tabs>
6363

64-
:::note Extras on conda-forge
65-
66-
Conda doesn't support optional extras. On conda-forge, install the `brotli-python` package directly alongside the client. It provides the same `brotli` module as the PyPI extra.
67-
68-
:::
69-
7064
For details, see [HTTP compression](../02_concepts/13_http_compression.mdx).
7165

7266
## Quick example

‎docs/04_upgrading/upgrading_to_v3.mdx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ client.key_value_store('my-store').set_record('my-key', {'data': 1}, 'applicatio
8181
client.run('my-run').charge('my-event', 5, 'my-idempotency-key')
8282

8383
# After
84-
client.key_value_store('my-store').set_record('my-key', {'data': 1}, content_type='application/json')
84+
client.key_value_store('my-store').set_record(
85+
'my-key', {'data': 1}, content_type='application/json'
86+
)
8587
client.run('my-run').charge('my-event', count=5, idempotency_key='my-idempotency-key')
8688
```
8789

@@ -97,10 +99,10 @@ Generated enum-like types are now [`Literal`](https://docs.python.org/3/library/
9799

98100
```python
99101
# Before
100-
event_types=[WebhookEventType.ACTOR_RUN_SUCCEEDED]
102+
event_types = [WebhookEventType.ACTOR_RUN_SUCCEEDED]
101103

102104
# After
103-
event_types=['ACTOR.RUN.SUCCEEDED']
105+
event_types = ['ACTOR.RUN.SUCCEEDED']
104106
```
105107

106108
Affected types: `ActorJobStatus`, `ActorPermissionLevel`, `ErrorType`, `GeneralAccess`, `HttpMethod`, `RunOrigin`, `SourceCodeFileFormat`, `StorageOwnership`, `VersionSourceType`, `WebhookDispatchStatus`, `WebhookEventType`. For more on the generated types and how they fit into the typed client surface, see [Typed models](/api/client/python/docs/concepts/typed-models).

‎pyproject.toml‎

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
[build-system]
2-
requires = ["hatchling"]
3-
build-backend = "hatchling.build"
2+
requires = ["uv_build"]
3+
build-backend = "uv_build"
44

55
[project]
66
name = "apify_client"
77
version = "3.1.1"
88
description = "Apify API client for Python"
99
authors = [{ name = "Apify Technologies s.r.o.", email = "support@apify.com" }]
10-
license = { file = "LICENSE" }
10+
license = "Apache-2.0"
11+
license-files = ["LICENSE"]
1112
readme = "README.md"
1213
requires-python = ">=3.11"
1314
classifiers = [
1415
"Development Status :: 5 - Production/Stable",
1516
"Environment :: Console",
1617
"Intended Audience :: Developers",
17-
"License :: OSI Approved :: Apache Software License",
1818
"Operating System :: OS Independent",
1919
"Programming Language :: Python :: 3.11",
2020
"Programming Language :: Python :: 3.12",
@@ -60,38 +60,30 @@ dev = [
6060
"pytest-timeout<3.0.0",
6161
"pytest-xdist<4.0.0",
6262
"pytest<10.0.0",
63-
"ruff~=0.15.0",
63+
"ruff~=0.16.0",
6464
"setuptools", # setuptools are used by pytest but not explicitly required
6565
"types-colorama<0.5.0",
6666
"ty~=0.0.0",
6767
"werkzeug<4.0.0", # Werkzeug is used by pytest-httpserver
6868
]
6969

70-
[tool.hatch.build.targets.wheel]
71-
packages = ["src/apify_client"]
72-
73-
[tool.hatch.build.targets.sdist]
74-
only-include = [
75-
"src/apify_client",
76-
"CHANGELOG.md",
77-
"CONTRIBUTING.md",
78-
"LICENSE",
79-
"README.md",
80-
"pyproject.toml",
81-
]
70+
[tool.uv.build-backend]
71+
# The module, pyproject.toml, README, and LICENSE are included in the sdist by default.
72+
source-include = ["CHANGELOG.md", "CONTRIBUTING.md"]
8273

8374
[tool.ruff]
8475
line-length = 120
8576
include = [
86-
"src/**/*.py",
87-
"tests/**/*.py",
88-
"scripts/**/*.py",
89-
"docs/**/*.py",
90-
"website/**/*.py",
77+
"**/*.py",
78+
# Ruff formats Python code blocks embedded in Markdown files.
79+
"**/*.md",
80+
"**/*.mdx",
9181
]
9282
exclude = [
9383
"website/versioned_docs/**",
9484
]
85+
# MDX is Markdown; without this mapping Ruff would try to parse `.mdx` files as Python.
86+
extension = { mdx = "markdown" }
9587

9688
[tool.ruff.lint]
9789
select = ["ALL"]
@@ -101,6 +93,7 @@ ignore = [
10193
"BLE001", # Do not catch blind exception
10294
"C901", # `{name}` is too complex
10395
"COM812", # This rule may cause conflicts when used with the formatter
96+
"CPY001", # Missing copyright notice at top of file
10497
"D100", # Missing docstring in public module
10598
"D104", # Missing docstring in public package
10699
"D107", # Missing docstring in `__init__`

‎src/apify_client/_models.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3828,7 +3828,10 @@ class Webhook(BaseModel):
38283828
condition: WebhookCondition
38293829
ignore_ssl_errors: Annotated[bool, Field(examples=[False])]
38303830
do_not_retry: Annotated[bool | None, Field(examples=[False])] = None
3831-
request_url: Annotated[AnyUrl | None, Field(examples=['http://example.com/'])]
3831+
request_url: Annotated[AnyUrl | None, Field(examples=['http://example.com/'])] = None
3832+
"""
3833+
URL of the HTTP request sent by the webhook. It is omitted or `null` for hook actions other than the conventional HTTP case (e.g. Slack or email notifications).
3834+
"""
38323835
payload_template: Annotated[str | None, Field(examples=['{\\n "userId": {{userId}}...'])] = None
38333836
headers_template: Annotated[str | None, Field(examples=['{\\n "Authorization": "Bearer ..."}'])] = None
38343837
description: Annotated[str | None, Field(examples=['this is webhook description'])] = None
@@ -3903,6 +3906,9 @@ class WebhookDispatchWebhookSummary(BaseModel):
39033906
action_type: Annotated[str | None, Field(examples=['HTTP_REQUEST'])] = None
39043907
condition: WebhookCondition | None = None
39053908
request_url: Annotated[AnyUrl | None, Field(examples=['https://example.com/webhook'])] = None
3909+
"""
3910+
URL of the HTTP request sent by the webhook. It is `null` for hook actions other than the conventional HTTP case (e.g. Slack or email notifications).
3911+
"""
39063912
is_ad_hoc: Annotated[bool | None, Field(examples=[False])] = None
39073913

39083914

‎src/apify_client/_pagination.py‎

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class HasItems(Protocol[T]):
2020
"""Structural contract for a single page of results from a paginated API endpoint.
2121
22-
Implementations must expose `items`. They may optionally expose `count` — the number of items scanned by the API for
22+
Implementations must expose `items`. They may optionally expose `count` - the number of items scanned by the API for
2323
this page, which can exceed `len(items)` when filters drop items from the response. The iterator helpers consult
2424
`count` opportunistically via `getattr` for offset bookkeeping and fall back to `len(items)` when it is absent.
2525
"""
@@ -41,8 +41,11 @@ def get_items_iterator(
4141
is used for offset bookkeeping (the Apify API's `count` reflects items scanned, which can exceed items returned when
4242
filters are applied).
4343
44-
Iteration stops when a page returns no items or when the user-requested `limit` is reached. The `total` field is
45-
intentionally not consulted, because it can change between calls.
44+
Iteration stops when a page scans no items (`count` is `0`, or `items` is empty when `count` is absent) or when the
45+
user-requested `limit` is reached. A page can scan items while returning none - filters like `clean` drop items from
46+
`items` but still count toward `count` - so terminating on scanned rather than returned items keeps the iterator
47+
advancing across fully-filtered pages. The `total` field is intentionally not consulted, because it can change
48+
between calls.
4649
4750
Args:
4851
callback: Function returning a single page of items.
@@ -62,9 +65,10 @@ def get_items_iterator(
6265
)
6366
yield from current_page.items
6467

65-
fetched_items += max(getattr(current_page, 'count', 0), len(current_page.items))
68+
page_scanned = max(getattr(current_page, 'count', 0), len(current_page.items))
69+
fetched_items += page_scanned
6670

67-
if not current_page.items or (initial_limit and fetched_items >= initial_limit):
71+
if not page_scanned or (initial_limit and fetched_items >= initial_limit):
6872
break
6973

7074

@@ -92,9 +96,10 @@ async def get_items_iterator_async(
9296
for item in current_page.items:
9397
yield item
9498

95-
fetched_items += max(getattr(current_page, 'count', 0), len(current_page.items))
99+
page_scanned = max(getattr(current_page, 'count', 0), len(current_page.items))
100+
fetched_items += page_scanned
96101

97-
if not current_page.items or (initial_limit and fetched_items >= initial_limit):
102+
if not page_scanned or (initial_limit and fetched_items >= initial_limit):
98103
break
99104

100105

@@ -124,8 +129,11 @@ def get_cursor_iterator(
124129
"""Yield individual items from cursor-paginated API responses.
125130
126131
Cursor pagination is restricted to the two API responses that expose it: `ListOfKeys` (for key-value store keys) and
127-
`ListOfRequests` (for request queue requests). Iteration ends when a page returns no items, the next cursor is
128-
`None`, or the user-requested `limit` is reached.
132+
`ListOfRequests` (for request queue requests). Iteration ends when the next cursor is `None` or the user-requested
133+
`limit` is reached. Emptiness alone does not stop iteration: server-side filters (such as the request-queue state
134+
`filter`) can drop every item on a page while a live cursor still points at more data, so termination relies on the
135+
cursor, not on whether a page returned items. Unlike offset responses, cursor responses expose no scanned-item
136+
`count`, so `count` cannot be used to detect a fully-filtered page here.
129137
130138
Args:
131139
callback: Function returning a single page of items. Receives `cursor` and `limit` kwargs.
@@ -144,12 +152,12 @@ def get_cursor_iterator(
144152
)
145153
yield from current_page.items
146154

147-
fetched_items += max(getattr(current_page, 'count', 0), len(current_page.items))
155+
fetched_items += len(current_page.items)
148156
cursor = (
149157
current_page.next_exclusive_start_key if isinstance(current_page, ListOfKeys) else current_page.next_cursor
150158
)
151159

152-
if not current_page.items or cursor is None or (initial_limit and fetched_items >= initial_limit):
160+
if cursor is None or (initial_limit and fetched_items >= initial_limit):
153161
break
154162

155163

@@ -189,12 +197,12 @@ async def get_cursor_iterator_async(
189197
for item in current_page.items:
190198
yield item
191199

192-
fetched_items += max(getattr(current_page, 'count', 0), len(current_page.items))
200+
fetched_items += len(current_page.items)
193201
cursor = (
194202
current_page.next_exclusive_start_key if isinstance(current_page, ListOfKeys) else current_page.next_cursor
195203
)
196204

197-
if not current_page.items or cursor is None or (initial_limit and fetched_items >= initial_limit):
205+
if cursor is None or (initial_limit and fetched_items >= initial_limit):
198206
break
199207

200208

0 commit comments

Comments
 (0)