From 88d6242a0731187d2a15c6183c0c2288ba7431af Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 14 Jul 2026 10:49:18 +0000 Subject: [PATCH 1/3] refactor!: Remove unused Configuration fields Remove the dead `disable_outdated_warning`, `fact`, and `max_paid_dataset_items` fields from `Configuration` for the upcoming major release. The SDK never read any of them, and `Actor.get_env()` no longer includes their keys. The corresponding `ActorEnvVars` / `ApifyEnvVars` enum entries for the platform environment variables remain available. The pay-per-event transition docs example now reads the `ACTOR_MAX_PAID_DATASET_ITEMS` environment variable directly, and the removal is documented in the v4 upgrading guide. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01FSLrkjZjrkren6sxUw2TYR --- .../code/11_conditional_actor_charge.py | 3 ++- docs/04_upgrading/upgrading_to_v4.md | 20 ++++++++++++++++++- src/apify/_configuration.py | 20 ------------------- tests/unit/actor/test_actor_env_helpers.py | 3 --- tests/unit/actor/test_configuration.py | 15 -------------- 5 files changed, 21 insertions(+), 40 deletions(-) diff --git a/docs/02_concepts/code/11_conditional_actor_charge.py b/docs/02_concepts/code/11_conditional_actor_charge.py index e0110737..90422ba0 100644 --- a/docs/02_concepts/code/11_conditional_actor_charge.py +++ b/docs/02_concepts/code/11_conditional_actor_charge.py @@ -1,4 +1,5 @@ import asyncio +import os from apify import Actor @@ -15,7 +16,7 @@ async def main() -> None: if Actor.get_charging_manager().get_pricing_info().is_pay_per_event: # highlight-end await Actor.push_data({'hello': 'world'}, charged_event_name='dataset-item') - elif charged_items < (Actor.configuration.max_paid_dataset_items or 0): + elif charged_items < int(os.environ.get('ACTOR_MAX_PAID_DATASET_ITEMS') or 0): await Actor.push_data({'hello': 'world'}) charged_items += 1 diff --git a/docs/04_upgrading/upgrading_to_v4.md b/docs/04_upgrading/upgrading_to_v4.md index edb105a7..ee566930 100644 --- a/docs/04_upgrading/upgrading_to_v4.md +++ b/docs/04_upgrading/upgrading_to_v4.md @@ -31,7 +31,7 @@ await Actor.charge('my-event', count=5) ## Removal of deprecated APIs -Methods and arguments that had been deprecated in v3 are removed in v4. +Methods and arguments that had been deprecated in v3 are removed in v4, along with a few `Configuration` fields that the SDK never read. ### api_public_base_url argument of storage clients @@ -71,6 +71,24 @@ The deprecated `latest_sdk_version`, `log_format`, and `standby_port` fields hav - In place of `standby_port`, use `web_server_port`. - `latest_sdk_version` and `log_format` don't have replacement. SDK version checking isn't supported for the Python SDK and the log format should be adjusted in code instead. +### Unused Configuration fields + +The `disable_outdated_warning`, `fact`, and `max_paid_dataset_items` fields have been removed from `Configuration`. The SDK never read any of them, and `Actor.get_env()` no longer includes their keys. The corresponding `ActorEnvVars.MAX_PAID_DATASET_ITEMS`, `ApifyEnvVars.DISABLE_OUTDATED_WARNING`, and `ApifyEnvVars.FACT` enum entries remain available. + +- `disable_outdated_warning` and `fact` have no replacement. SDK version checking isn't supported for the Python SDK, so there is no outdated-version warning to disable. +- `max_paid_dataset_items` only mirrored the `ACTOR_MAX_PAID_DATASET_ITEMS` environment variable — read the environment variable directly instead: + +```python +import os + +# Before (v3) +max_paid_dataset_items = Actor.configuration.max_paid_dataset_items + +# After (v4) +env_value = os.environ.get('ACTOR_MAX_PAID_DATASET_ITEMS') +max_paid_dataset_items = int(env_value) if env_value else None +``` + ### wait_for_finish argument of Actor.start The `wait_for_finish` argument of `Actor.start()` has been removed. It contradicted the purpose of `Actor.start()`, which only starts the run without waiting for it to finish. The JS SDK does not expose it on `Actor.start()` either. To wait for a run to finish, use `Actor.call()`. diff --git a/src/apify/_configuration.py b/src/apify/_configuration.py index 9731696b..982ba37e 100644 --- a/src/apify/_configuration.py +++ b/src/apify/_configuration.py @@ -264,17 +264,6 @@ class Configuration(CrawleeConfiguration): ), ] = None - disable_outdated_warning: Annotated[ - bool, - Field( - validation_alias='apify_disable_outdated_warning', - description='Controls the display of outdated SDK version warnings', - ), - BeforeValidator(lambda val: val or False), - ] = False - - fact: Annotated[str | None, Field(validation_alias='apify_fact')] = None - input_key: Annotated[ str, Field( @@ -311,15 +300,6 @@ class Configuration(CrawleeConfiguration): ), ] = False - max_paid_dataset_items: Annotated[ - int | None, - Field( - validation_alias='actor_max_paid_dataset_items', - description='For paid-per-result Actors, the user-set limit on returned results. Do not exceed this limit', - ), - BeforeValidator(_default_if_empty(default=None)), - ] = None - max_total_charge_usd: Annotated[ Decimal | None, Field( diff --git a/tests/unit/actor/test_actor_env_helpers.py b/tests/unit/actor/test_actor_env_helpers.py index 8b67637e..459f3f84 100644 --- a/tests/unit/actor/test_actor_env_helpers.py +++ b/tests/unit/actor/test_actor_env_helpers.py @@ -12,7 +12,6 @@ from apify._consts import ActorEnvVars, ApifyEnvVars INTEGER_ENV_VARS: list[ActorEnvVars | ApifyEnvVars] = [ - ActorEnvVars.MAX_PAID_DATASET_ITEMS, ActorEnvVars.MEMORY_MBYTES, ActorEnvVars.STANDBY_PORT, ActorEnvVars.WEB_SERVER_PORT, @@ -31,7 +30,6 @@ BOOL_ENV_VARS: list[ApifyEnvVars] = [ ApifyEnvVars.DISABLE_BROWSER_SANDBOX, - ApifyEnvVars.DISABLE_OUTDATED_WARNING, ApifyEnvVars.HEADLESS, ApifyEnvVars.IS_AT_HOME, ApifyEnvVars.PERSIST_STORAGE, @@ -62,7 +60,6 @@ ApifyEnvVars.API_BASE_URL, ApifyEnvVars.API_PUBLIC_BASE_URL, ApifyEnvVars.DEFAULT_BROWSER_PATH, - ApifyEnvVars.FACT, ApifyEnvVars.INPUT_SECRETS_PRIVATE_KEY_FILE, ApifyEnvVars.INPUT_SECRETS_PRIVATE_KEY_PASSPHRASE, ApifyEnvVars.LOCAL_STORAGE_DIR, diff --git a/tests/unit/actor/test_configuration.py b/tests/unit/actor/test_configuration.py index 486cbe07..dfaeca2a 100644 --- a/tests/unit/actor/test_configuration.py +++ b/tests/unit/actor/test_configuration.py @@ -276,13 +276,6 @@ def test_default_values() -> None: assert config.test_pay_per_event is False -def test_max_paid_dataset_items_zero_is_preserved(monkeypatch: pytest.MonkeyPatch) -> None: - """Test that max_paid_dataset_items=0 is not treated as falsy and converted to None.""" - monkeypatch.setenv('ACTOR_MAX_PAID_DATASET_ITEMS', '0') - config = ApifyConfiguration() - assert config.max_paid_dataset_items == 0 - - def test_max_total_charge_usd_zero_is_preserved(monkeypatch: pytest.MonkeyPatch) -> None: """Test that max_total_charge_usd=0 is not treated as falsy and converted to None.""" monkeypatch.setenv('ACTOR_MAX_TOTAL_CHARGE_USD', '0') @@ -290,13 +283,6 @@ def test_max_total_charge_usd_zero_is_preserved(monkeypatch: pytest.MonkeyPatch) assert config.max_total_charge_usd == Decimal(0) -def test_max_paid_dataset_items_empty_string_becomes_none(monkeypatch: pytest.MonkeyPatch) -> None: - """Test that an empty env var for max_paid_dataset_items is converted to None.""" - monkeypatch.setenv('ACTOR_MAX_PAID_DATASET_ITEMS', '') - config = ApifyConfiguration() - assert config.max_paid_dataset_items is None - - def test_max_total_charge_usd_empty_string_becomes_none(monkeypatch: pytest.MonkeyPatch) -> None: """Test that an empty env var for max_total_charge_usd is converted to None.""" monkeypatch.setenv('ACTOR_MAX_TOTAL_CHARGE_USD', '') @@ -398,7 +384,6 @@ def test_actor_storage_json_env_var(monkeypatch: pytest.MonkeyPatch) -> None: ('env_var', 'attr', 'expected'), [ ('APIFY_TIMEOUT_AT', 'timeout_at', None), - ('ACTOR_MAX_PAID_DATASET_ITEMS', 'max_paid_dataset_items', None), ('ACTOR_MAX_TOTAL_CHARGE_USD', 'max_total_charge_usd', None), ('APIFY_USER_IS_PAYING', 'user_is_paying', False), ], From 8bcabe85b52f669ddc9dce14579577fbf18ce344 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Thu, 16 Jul 2026 12:55:52 +0200 Subject: [PATCH 2/3] refactor: keep max_paid_dataset_items config field, remove only disable_outdated_warning and fact --- .../code/11_conditional_actor_charge.py | 3 +-- docs/04_upgrading/upgrading_to_v4.md | 16 ++-------------- src/apify/_configuration.py | 9 +++++++++ tests/unit/actor/test_actor_env_helpers.py | 1 + tests/unit/actor/test_configuration.py | 15 +++++++++++++++ 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/docs/02_concepts/code/11_conditional_actor_charge.py b/docs/02_concepts/code/11_conditional_actor_charge.py index 90422ba0..e0110737 100644 --- a/docs/02_concepts/code/11_conditional_actor_charge.py +++ b/docs/02_concepts/code/11_conditional_actor_charge.py @@ -1,5 +1,4 @@ import asyncio -import os from apify import Actor @@ -16,7 +15,7 @@ async def main() -> None: if Actor.get_charging_manager().get_pricing_info().is_pay_per_event: # highlight-end await Actor.push_data({'hello': 'world'}, charged_event_name='dataset-item') - elif charged_items < int(os.environ.get('ACTOR_MAX_PAID_DATASET_ITEMS') or 0): + elif charged_items < (Actor.configuration.max_paid_dataset_items or 0): await Actor.push_data({'hello': 'world'}) charged_items += 1 diff --git a/docs/04_upgrading/upgrading_to_v4.md b/docs/04_upgrading/upgrading_to_v4.md index ee566930..dc7f1f3e 100644 --- a/docs/04_upgrading/upgrading_to_v4.md +++ b/docs/04_upgrading/upgrading_to_v4.md @@ -73,21 +73,9 @@ The deprecated `latest_sdk_version`, `log_format`, and `standby_port` fields hav ### Unused Configuration fields -The `disable_outdated_warning`, `fact`, and `max_paid_dataset_items` fields have been removed from `Configuration`. The SDK never read any of them, and `Actor.get_env()` no longer includes their keys. The corresponding `ActorEnvVars.MAX_PAID_DATASET_ITEMS`, `ApifyEnvVars.DISABLE_OUTDATED_WARNING`, and `ApifyEnvVars.FACT` enum entries remain available. +The `disable_outdated_warning` and `fact` fields have been removed from `Configuration`. The SDK never read either of them, and `Actor.get_env()` no longer includes their keys. The corresponding `ApifyEnvVars.DISABLE_OUTDATED_WARNING` and `ApifyEnvVars.FACT` enum entries remain available. -- `disable_outdated_warning` and `fact` have no replacement. SDK version checking isn't supported for the Python SDK, so there is no outdated-version warning to disable. -- `max_paid_dataset_items` only mirrored the `ACTOR_MAX_PAID_DATASET_ITEMS` environment variable — read the environment variable directly instead: - -```python -import os - -# Before (v3) -max_paid_dataset_items = Actor.configuration.max_paid_dataset_items - -# After (v4) -env_value = os.environ.get('ACTOR_MAX_PAID_DATASET_ITEMS') -max_paid_dataset_items = int(env_value) if env_value else None -``` +Neither has a replacement. SDK version checking isn't supported for the Python SDK, so there's no outdated-version warning to disable. ### wait_for_finish argument of Actor.start diff --git a/src/apify/_configuration.py b/src/apify/_configuration.py index 982ba37e..cdd801c9 100644 --- a/src/apify/_configuration.py +++ b/src/apify/_configuration.py @@ -300,6 +300,15 @@ class Configuration(CrawleeConfiguration): ), ] = False + max_paid_dataset_items: Annotated[ + int | None, + Field( + validation_alias='actor_max_paid_dataset_items', + description='For paid-per-result Actors, the user-set limit on returned results. Do not exceed this limit', + ), + BeforeValidator(_default_if_empty(default=None)), + ] = None + max_total_charge_usd: Annotated[ Decimal | None, Field( diff --git a/tests/unit/actor/test_actor_env_helpers.py b/tests/unit/actor/test_actor_env_helpers.py index 459f3f84..0d5adfdb 100644 --- a/tests/unit/actor/test_actor_env_helpers.py +++ b/tests/unit/actor/test_actor_env_helpers.py @@ -12,6 +12,7 @@ from apify._consts import ActorEnvVars, ApifyEnvVars INTEGER_ENV_VARS: list[ActorEnvVars | ApifyEnvVars] = [ + ActorEnvVars.MAX_PAID_DATASET_ITEMS, ActorEnvVars.MEMORY_MBYTES, ActorEnvVars.STANDBY_PORT, ActorEnvVars.WEB_SERVER_PORT, diff --git a/tests/unit/actor/test_configuration.py b/tests/unit/actor/test_configuration.py index dfaeca2a..486cbe07 100644 --- a/tests/unit/actor/test_configuration.py +++ b/tests/unit/actor/test_configuration.py @@ -276,6 +276,13 @@ def test_default_values() -> None: assert config.test_pay_per_event is False +def test_max_paid_dataset_items_zero_is_preserved(monkeypatch: pytest.MonkeyPatch) -> None: + """Test that max_paid_dataset_items=0 is not treated as falsy and converted to None.""" + monkeypatch.setenv('ACTOR_MAX_PAID_DATASET_ITEMS', '0') + config = ApifyConfiguration() + assert config.max_paid_dataset_items == 0 + + def test_max_total_charge_usd_zero_is_preserved(monkeypatch: pytest.MonkeyPatch) -> None: """Test that max_total_charge_usd=0 is not treated as falsy and converted to None.""" monkeypatch.setenv('ACTOR_MAX_TOTAL_CHARGE_USD', '0') @@ -283,6 +290,13 @@ def test_max_total_charge_usd_zero_is_preserved(monkeypatch: pytest.MonkeyPatch) assert config.max_total_charge_usd == Decimal(0) +def test_max_paid_dataset_items_empty_string_becomes_none(monkeypatch: pytest.MonkeyPatch) -> None: + """Test that an empty env var for max_paid_dataset_items is converted to None.""" + monkeypatch.setenv('ACTOR_MAX_PAID_DATASET_ITEMS', '') + config = ApifyConfiguration() + assert config.max_paid_dataset_items is None + + def test_max_total_charge_usd_empty_string_becomes_none(monkeypatch: pytest.MonkeyPatch) -> None: """Test that an empty env var for max_total_charge_usd is converted to None.""" monkeypatch.setenv('ACTOR_MAX_TOTAL_CHARGE_USD', '') @@ -384,6 +398,7 @@ def test_actor_storage_json_env_var(monkeypatch: pytest.MonkeyPatch) -> None: ('env_var', 'attr', 'expected'), [ ('APIFY_TIMEOUT_AT', 'timeout_at', None), + ('ACTOR_MAX_PAID_DATASET_ITEMS', 'max_paid_dataset_items', None), ('ACTOR_MAX_TOTAL_CHARGE_USD', 'max_total_charge_usd', None), ('APIFY_USER_IS_PAYING', 'user_is_paying', False), ], From 7c4acd960093e08aa2446b2a97d645a57bcbc45f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20Proch=C3=A1zka?= Date: Thu, 16 Jul 2026 13:53:32 +0200 Subject: [PATCH 3/3] Update docs/04_upgrading/upgrading_to_v4.md Co-authored-by: Edyta <142720610+szaganek@users.noreply.github.com> --- docs/04_upgrading/upgrading_to_v4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/04_upgrading/upgrading_to_v4.md b/docs/04_upgrading/upgrading_to_v4.md index dc7f1f3e..d5491add 100644 --- a/docs/04_upgrading/upgrading_to_v4.md +++ b/docs/04_upgrading/upgrading_to_v4.md @@ -71,7 +71,7 @@ The deprecated `latest_sdk_version`, `log_format`, and `standby_port` fields hav - In place of `standby_port`, use `web_server_port`. - `latest_sdk_version` and `log_format` don't have replacement. SDK version checking isn't supported for the Python SDK and the log format should be adjusted in code instead. -### Unused Configuration fields +### Unused `Configuration` fields The `disable_outdated_warning` and `fact` fields have been removed from `Configuration`. The SDK never read either of them, and `Actor.get_env()` no longer includes their keys. The corresponding `ApifyEnvVars.DISABLE_OUTDATED_WARNING` and `ApifyEnvVars.FACT` enum entries remain available.