Skip to content

Commit ece4fd8

Browse files
vdusekclaude
andcommitted
docs: Improve and polish docstrings for all public classes
Improve class-level docstrings for Apify API clients, resource clients, HTTP clients, and error classes to be more descriptive and consistent. Resource client docstrings now describe key operations and reference how to obtain an instance via the parent client. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3966ec0 commit ece4fd8

32 files changed

Lines changed: 389 additions & 153 deletions

src/apify_client/_apify_client.py

Lines changed: 82 additions & 66 deletions
Large diffs are not rendered by default.

src/apify_client/_http_clients/_http_client.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@
3030

3131
@docs_group('HTTP clients')
3232
class HttpClient(BaseHttpClient):
33-
"""Synchronous HTTP client for Apify API with automatic retries and exponential backoff."""
33+
"""Synchronous HTTP client for the Apify API.
34+
35+
Handles authentication, request serialization, and automatic retries with exponential backoff
36+
for rate-limited (HTTP 429) and server error (HTTP 5xx) responses. Non-retryable errors
37+
(e.g. HTTP 4xx client errors) are raised immediately.
38+
"""
3439

3540
def __init__(
3641
self,
@@ -46,9 +51,9 @@ def __init__(
4651
4752
Args:
4853
token: Apify API token for authentication.
49-
timeout: Request timeout.
50-
max_retries: Maximum number of retries for failed requests.
51-
min_delay_between_retries: Minimum delay between retries.
54+
timeout: Default timeout for HTTP requests.
55+
max_retries: Maximum number of retry attempts for failed requests.
56+
min_delay_between_retries: Minimum delay between retries (increases exponentially with each attempt).
5257
statistics: Statistics tracker for API calls. Created automatically if not provided.
5358
headers: Additional HTTP headers to include in all requests.
5459
"""
@@ -251,7 +256,12 @@ def stop_retrying() -> None:
251256

252257
@docs_group('HTTP clients')
253258
class HttpClientAsync(BaseHttpClient):
254-
"""Asynchronous HTTP client for Apify API with automatic retries and exponential backoff."""
259+
"""Asynchronous HTTP client for the Apify API.
260+
261+
Handles authentication, request serialization, and automatic retries with exponential backoff
262+
for rate-limited (HTTP 429) and server error (HTTP 5xx) responses. Non-retryable errors
263+
(e.g. HTTP 4xx client errors) are raised immediately.
264+
"""
255265

256266
def __init__(
257267
self,
@@ -267,9 +277,9 @@ def __init__(
267277
268278
Args:
269279
token: Apify API token for authentication.
270-
timeout: Request timeout.
271-
max_retries: Maximum number of retries for failed requests.
272-
min_delay_between_retries: Minimum delay between retries.
280+
timeout: Default timeout for HTTP requests.
281+
max_retries: Maximum number of retry attempts for failed requests.
282+
min_delay_between_retries: Minimum delay between retries (increases exponentially with each attempt).
273283
statistics: Statistics tracker for API calls. Created automatically if not provided.
274284
headers: Additional HTTP headers to include in all requests.
275285
"""

src/apify_client/_resource_clients/actor.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@
5050

5151
@docs_group('Resource clients')
5252
class ActorClient(ResourceClient):
53-
"""Sub-client for manipulating a single Actor."""
53+
"""Sub-client for managing a specific Actor.
54+
55+
Provides methods to get, update, delete, build, and start runs of an Actor.
56+
Obtain an instance via `ApifyClient.actor`.
57+
"""
5458

5559
def __init__(
5660
self,
@@ -510,7 +514,11 @@ def validate_input(
510514

511515
@docs_group('Resource clients')
512516
class ActorClientAsync(ResourceClientAsync):
513-
"""Async sub-client for manipulating a single Actor."""
517+
"""Sub-client for managing a specific Actor.
518+
519+
Provides methods to get, update, delete, build, and start runs of an Actor.
520+
Obtain an instance via `ApifyClientAsync.actor`.
521+
"""
514522

515523
def __init__(
516524
self,

src/apify_client/_resource_clients/actor_collection.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414

1515
@docs_group('Resource clients')
1616
class ActorCollectionClient(ResourceClient):
17-
"""Sub-client for manipulating Actors."""
17+
"""Sub-client for the Actor collection.
18+
19+
Provides methods to list and create Actors. Obtain an instance via `ApifyClient.actors`.
20+
"""
1821

1922
def __init__(self, *args: Any, **kwargs: Any) -> None:
2023
resource_path = kwargs.pop('resource_path', 'acts')
@@ -142,7 +145,10 @@ def create(
142145

143146
@docs_group('Resource clients')
144147
class ActorCollectionClientAsync(ResourceClientAsync):
145-
"""Async sub-client for manipulating Actors."""
148+
"""Sub-client for the Actor collection.
149+
150+
Provides methods to list and create Actors. Obtain an instance via `ApifyClientAsync.actors`.
151+
"""
146152

147153
def __init__(self, *args: Any, **kwargs: Any) -> None:
148154
resource_path = kwargs.pop('resource_path', 'acts')

src/apify_client/_resource_clients/actor_env_var.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ def get_actor_env_var_representation(
2424

2525
@docs_group('Resource clients')
2626
class ActorEnvVarClient(ResourceClient):
27-
"""Sub-client for manipulating a single Actor environment variable."""
27+
"""Sub-client for managing a specific Actor environment variable.
28+
29+
Provides methods to get, update, and delete an environment variable.
30+
Obtain an instance via `ActorVersionClient.env_var`.
31+
"""
2832

2933
def __init__(self, *args: Any, **kwargs: Any) -> None:
3034
resource_path = kwargs.pop('resource_path', 'env-vars')
@@ -81,7 +85,11 @@ def delete(self) -> None:
8185

8286
@docs_group('Resource clients')
8387
class ActorEnvVarClientAsync(ResourceClientAsync):
84-
"""Async sub-client for manipulating a single Actor environment variable."""
88+
"""Sub-client for managing a specific Actor environment variable.
89+
90+
Provides methods to get, update, and delete an environment variable.
91+
Obtain an instance via `ActorVersionClientAsync.env_var`.
92+
"""
8593

8694
def __init__(self, *args: Any, **kwargs: Any) -> None:
8795
resource_path = kwargs.pop('resource_path', 'env-vars')

src/apify_client/_resource_clients/actor_env_var_collection.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111

1212
@docs_group('Resource clients')
1313
class ActorEnvVarCollectionClient(ResourceClient):
14-
"""Sub-client for manipulating Actor env vars."""
14+
"""Sub-client for the Actor environment variable collection.
15+
16+
Provides methods to list and create environment variables.
17+
Obtain an instance via `ActorVersionClient.env_vars`.
18+
"""
1519

1620
def __init__(self, *args: Any, **kwargs: Any) -> None:
1721
resource_path = kwargs.pop('resource_path', 'env-vars')
@@ -59,7 +63,11 @@ def create(
5963

6064
@docs_group('Resource clients')
6165
class ActorEnvVarCollectionClientAsync(ResourceClientAsync):
62-
"""Async sub-client for manipulating Actor env vars."""
66+
"""Sub-client for the Actor environment variable collection.
67+
68+
Provides methods to list and create environment variables.
69+
Obtain an instance via `ActorVersionClientAsync.env_vars`.
70+
"""
6371

6472
def __init__(self, *args: Any, **kwargs: Any) -> None:
6573
resource_path = kwargs.pop('resource_path', 'env-vars')

src/apify_client/_resource_clients/actor_version.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919

2020
@docs_group('Resource clients')
2121
class ActorVersionClient(ResourceClient):
22-
"""Sub-client for manipulating a single Actor version."""
22+
"""Sub-client for managing a specific Actor version.
23+
24+
Provides methods to get, update, and delete an Actor version.
25+
Obtain an instance via `ActorClient.version`.
26+
"""
2327

2428
def __init__(
2529
self,
@@ -125,7 +129,11 @@ def env_var(self, env_var_name: str) -> ActorEnvVarClient:
125129

126130
@docs_group('Resource clients')
127131
class ActorVersionClientAsync(ResourceClientAsync):
128-
"""Async sub-client for manipulating a single Actor version."""
132+
"""Sub-client for managing a specific Actor version.
133+
134+
Provides methods to get, update, and delete an Actor version.
135+
Obtain an instance via `ActorClientAsync.version`.
136+
"""
129137

130138
def __init__(
131139
self,

src/apify_client/_resource_clients/actor_version_collection.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717

1818
@docs_group('Resource clients')
1919
class ActorVersionCollectionClient(ResourceClient):
20-
"""Sub-client for manipulating Actor versions."""
20+
"""Sub-client for the Actor version collection.
21+
22+
Provides methods to list and create Actor versions.
23+
Obtain an instance via `ActorClient.versions`.
24+
"""
2125

2226
def __init__(self, *args: Any, **kwargs: Any) -> None:
2327
resource_path = kwargs.pop('resource_path', 'versions')
@@ -89,7 +93,11 @@ def create(
8993

9094
@docs_group('Resource clients')
9195
class ActorVersionCollectionClientAsync(ResourceClientAsync):
92-
"""Async sub-client for manipulating Actor versions."""
96+
"""Sub-client for the Actor version collection.
97+
98+
Provides methods to list and create Actor versions.
99+
Obtain an instance via `ActorClientAsync.versions`.
100+
"""
93101

94102
def __init__(self, *args: Any, **kwargs: Any) -> None:
95103
resource_path = kwargs.pop('resource_path', 'versions')

src/apify_client/_resource_clients/build.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515

1616
@docs_group('Resource clients')
1717
class BuildClient(ResourceClient):
18-
"""Sub-client for manipulating a single Actor build."""
18+
"""Sub-client for managing a specific Actor build.
19+
20+
Provides methods to get, delete, abort, and wait for finish of an Actor build.
21+
Obtain an instance via `ApifyClient.build`.
22+
"""
1923

2024
def __init__(
2125
self,
@@ -113,7 +117,11 @@ def log(self) -> LogClient:
113117

114118
@docs_group('Resource clients')
115119
class BuildClientAsync(ResourceClientAsync):
116-
"""Async sub-client for manipulating a single Actor build."""
120+
"""Sub-client for managing a specific Actor build.
121+
122+
Provides methods to get, delete, abort, and wait for finish of an Actor build.
123+
Obtain an instance via `ApifyClientAsync.build`.
124+
"""
117125

118126
def __init__(
119127
self,

src/apify_client/_resource_clients/build_collection.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99

1010
@docs_group('Resource clients')
1111
class BuildCollectionClient(ResourceClient):
12-
"""Sub-client for listing Actor builds."""
12+
"""Sub-client for the Actor build collection.
13+
14+
Provides methods to list Actor builds. Obtain an instance via `ApifyClient.builds`.
15+
"""
1316

1417
def __init__(self, *args: Any, **kwargs: Any) -> None:
1518
resource_path = kwargs.pop('resource_path', 'actor-builds')
@@ -44,7 +47,10 @@ def list(
4447

4548
@docs_group('Resource clients')
4649
class BuildCollectionClientAsync(ResourceClientAsync):
47-
"""Async sub-client for listing Actor builds."""
50+
"""Sub-client for the Actor build collection.
51+
52+
Provides methods to list Actor builds. Obtain an instance via `ApifyClientAsync.builds`.
53+
"""
4854

4955
def __init__(self, *args: Any, **kwargs: Any) -> None:
5056
resource_path = kwargs.pop('resource_path', 'actor-builds')

0 commit comments

Comments
 (0)