Skip to content

Commit 9e1bb22

Browse files
committed
refactor: Address review comments
1 parent 56f2959 commit 9e1bb22

6 files changed

Lines changed: 9 additions & 16 deletions

File tree

src/apify/_actor.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ async def start(
926926
raise ValueError(f'Invalid timeout {timeout!r}: expected `None`, `"inherit"`, or a `timedelta`.')
927927

928928
actor_client = client.actor(actor_id)
929-
run = await actor_client.start(
929+
return await actor_client.start(
930930
run_input=run_input,
931931
content_type=content_type,
932932
build=build,
@@ -939,11 +939,6 @@ async def start(
939939
webhooks=to_client_representations(webhooks),
940940
)
941941

942-
if run is None:
943-
raise RuntimeError(f'Failed to start Actor with ID "{actor_id}".')
944-
945-
return run
946-
947942
@_ensure_context
948943
async def abort(
949944
self,

src/apify/_charging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
_ensure_context = ensure_context('active')
4141

4242

43-
# --- SDK-side Actor pricing-info models ---------------------------------------------------------------
43+
# SDK-side Actor pricing-info models.
4444
#
4545
# These are thin subclasses of the `apify-client` pricing models. The Apify platform serializes Actor
4646
# pricing info into the `APIFY_ACTOR_PRICING_INFO` env var (parsed by `Configuration.actor_pricing_info`),

src/apify/_consts.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
EVENT_LISTENERS_TIMEOUT = timedelta(seconds=5)
88
"""Timeout for waiting on event listeners to finish during Actor exit."""
99

10+
BASE64_REGEXP = '[-A-Za-z0-9+/]*={0,3}'
11+
"""Regex fragment matching a single base64-encoded component."""
12+
1013
ENCRYPTED_STRING_VALUE_PREFIX = 'ENCRYPTED_VALUE'
1114
"""Prefix for encrypted string values in Actor input."""
1215

1316
ENCRYPTED_JSON_VALUE_PREFIX = 'ENCRYPTED_JSON'
1417
"""Prefix for encrypted JSON values in Actor input."""
1518

1619
ENCRYPTED_INPUT_VALUE_REGEXP = re.compile(
17-
r'^(ENCRYPTED_VALUE|ENCRYPTED_JSON):(?:([-A-Za-z0-9+/]*={0,3}):)?([-A-Za-z0-9+/]*={0,3}):([-A-Za-z0-9+/]*={0,3})$'
20+
f'^({ENCRYPTED_STRING_VALUE_PREFIX}|{ENCRYPTED_JSON_VALUE_PREFIX}):(?:({BASE64_REGEXP}):)?({BASE64_REGEXP}):({BASE64_REGEXP})$'
1821
)
1922
"""Regex matching encrypted input values with base64-encoded components."""
2023

src/apify/storage_clients/_apify/_alias_resolving.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import logging
44
from asyncio import Lock
5-
from datetime import timedelta
65
from functools import cached_property
76
from logging import getLogger
87
from typing import TYPE_CHECKING, ClassVar, Literal, overload
@@ -258,7 +257,6 @@ async def _get_default_kvs_client(configuration: Configuration) -> KeyValueStore
258257
token=configuration.token,
259258
api_url=configuration.api_base_url,
260259
max_retries=8,
261-
min_delay_between_retries=timedelta(milliseconds=500),
262260
)
263261

264262
if not configuration.default_key_value_store_id:

src/apify/storage_clients/_apify/_api_client_creation.py

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

3-
from datetime import timedelta
43
from typing import TYPE_CHECKING, Literal, overload
54

65
from apify_client import ApifyClientAsync
@@ -178,5 +177,4 @@ def _create_api_client(configuration: Configuration) -> ApifyClientAsync:
178177
api_url=configuration.api_base_url,
179178
api_public_url=configuration.api_public_base_url,
180179
max_retries=8,
181-
min_delay_between_retries=timedelta(milliseconds=500),
182180
)

tests/e2e/conftest.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ def apify_token() -> str:
4848
def apify_client_async(apify_token: str) -> ApifyClientAsync:
4949
"""Create an instance of the ApifyClientAsync."""
5050
api_url = os.getenv(_API_URL_ENV_VAR)
51-
52-
if api_url is not None:
53-
return ApifyClientAsync(apify_token, api_url=api_url)
54-
return ApifyClientAsync(apify_token)
51+
return (
52+
ApifyClientAsync(token=apify_token) if api_url is None else ApifyClientAsync(token=apify_token, api_url=api_url)
53+
)
5554

5655

5756
@pytest.fixture

0 commit comments

Comments
 (0)