Skip to content

Commit 104011c

Browse files
authored
feat: expose WebhooksList and JsonSerializable from public types module (#800)
## Summary - Move `WebhooksList` and `JsonSerializable` from the private `_internal_types.py` to the public `apify_client.types` module so users writing custom HTTP clients or consuming public method signatures can import them. - Update all internal importers to the new location and drop the now-empty `_internal_types.py` (its only remaining alias, `TerminalActorJobStatus`, had zero importers — the actually-used `_TerminalActorJobStatus` lives privately in `_resource_clients/_resource_client.py`).
1 parent 73bd98a commit 104011c

8 files changed

Lines changed: 39 additions & 48 deletions

File tree

src/apify_client/_internal_types.py

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/apify_client/_resource_clients/actor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
from decimal import Decimal
3636
from logging import Logger
3737

38-
from apify_client._internal_types import WebhooksList
3938
from apify_client._literals import ActorJobStatus, ActorPermissionLevel, RunOrigin
4039
from apify_client._resource_clients import (
4140
ActorVersionClient,
@@ -53,7 +52,7 @@
5352
WebhookCollectionClient,
5453
WebhookCollectionClientAsync,
5554
)
56-
from apify_client.types import Timeout
55+
from apify_client.types import Timeout, WebhooksList
5756

5857
_PricingInfo = (
5958
PayPerEventActorPricingInfo

src/apify_client/_resource_clients/dataset.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020
from collections.abc import AsyncIterator, Iterator
2121
from datetime import timedelta
2222

23-
from apify_client._internal_types import JsonSerializable
2423
from apify_client._literals import GeneralAccess
2524
from apify_client.http_clients import HttpResponse
26-
from apify_client.types import Timeout
25+
from apify_client.types import JsonSerializable, Timeout
2726

2827

2928
@docs_group('Other')

src/apify_client/_resource_clients/task.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
if TYPE_CHECKING:
2020
from datetime import timedelta
2121

22-
from apify_client._internal_types import WebhooksList
2322
from apify_client._literals import ActorJobStatus, RunOrigin
2423
from apify_client._resource_clients import (
2524
RunClient,
@@ -30,7 +29,7 @@
3029
WebhookCollectionClientAsync,
3130
)
3231
from apify_client._typeddicts import TaskInputDict
33-
from apify_client.types import Timeout
32+
from apify_client.types import Timeout, WebhooksList
3433

3534

3635
@docs_group('Resource clients')

src/apify_client/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
if TYPE_CHECKING:
2121
from datetime import timedelta
2222

23-
from apify_client._internal_types import WebhooksList
2423
from apify_client.errors import ApifyApiError
2524
from apify_client.http_clients import HttpResponse
25+
from apify_client.types import WebhooksList
2626

2727
T = TypeVar('T')
2828

src/apify_client/http_clients/_base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
if TYPE_CHECKING:
2626
from collections.abc import AsyncIterator, Iterator, Mapping
2727

28-
from apify_client._internal_types import JsonSerializable
29-
from apify_client.types import Timeout
28+
from apify_client.types import JsonSerializable, Timeout
3029

3130

3231
@docs_group('HTTP clients')

src/apify_client/http_clients/_impit.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727
if TYPE_CHECKING:
2828
from collections.abc import Awaitable, Callable
2929

30-
from apify_client._internal_types import JsonSerializable
3130
from apify_client._statistics import ClientStatistics
3231
from apify_client.http_clients._base import HttpResponse
33-
from apify_client.types import Timeout
32+
from apify_client.types import JsonSerializable, Timeout
3433

3534
T = TypeVar('T')
3635

src/apify_client/types.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,46 @@
33
from datetime import timedelta
44
from typing import Literal
55

6+
from apify_client._models import WebhookCreate, WebhookRepresentation
7+
from apify_client._typeddicts import (
8+
WebhookCreateCamelDict,
9+
WebhookCreateDict,
10+
WebhookRepresentationCamelDict,
11+
WebhookRepresentationDict,
12+
)
13+
614
Timeout = timedelta | Literal['no_timeout', 'short', 'medium', 'long']
715
"""Type for the `timeout` parameter on resource client methods.
816
917
`'short'`, `'medium'`, and `'long'` are tier literals resolved by the HTTP client to configured values.
1018
A `timedelta` overrides the timeout for this call, and `'no_timeout'` disables the timeout entirely.
1119
"""
1220

21+
WebhooksList = (
22+
list[WebhookCreate]
23+
| list[WebhookCreateDict]
24+
| list[WebhookCreateCamelDict]
25+
| list[WebhookRepresentation]
26+
| list[WebhookRepresentationDict]
27+
| list[WebhookRepresentationCamelDict]
28+
)
29+
"""Type for the `webhooks` parameter on resource-client `start`/`call` methods and `from_webhooks`.
30+
31+
`WebhookRepresentation` / `WebhookRepresentationDict` / `WebhookRepresentationCamelDict` are the minimal ad-hoc
32+
webhook shape (only `event_types` and `request_url` required). `WebhookCreate` / `WebhookCreateDict` /
33+
`WebhookCreateCamelDict` are accepted so a persistent-webhook definition can be reused; their fields not relevant
34+
to ad-hoc webhooks (e.g. `condition`) are ignored at runtime. The `*CamelDict` variants accept camelCase keys
35+
matching the Apify API spelling.
36+
"""
37+
38+
JsonSerializable = dict[str, 'JsonSerializable'] | list['JsonSerializable'] | str | int | float | bool | None
39+
"""Recursive type for JSON-serializable values - primitives plus objects and arrays with JSON-serializable contents.
40+
41+
Based on the definition discussed in https://github.com/python/typing/issues/182.
42+
"""
43+
1344
__all__ = [
45+
'JsonSerializable',
1446
'Timeout',
47+
'WebhooksList',
1548
]

0 commit comments

Comments
 (0)