diff --git a/.flake8 b/.flake8 index 5d383e28..6999bfcb 100644 --- a/.flake8 +++ b/.flake8 @@ -4,10 +4,12 @@ filename = ./scripts/*.py, ./src/*.py, ./tests/*.py +# Todo: remove "src/apify/consts.py: F401" once consts from apify-shared are not being reexported per-file-ignores = docs/*: D scripts/*: D tests/*: D + src/apify/consts.py: F401 # Google docstring convention + D204 & D401 docstring-convention = all diff --git a/.isort.cfg b/.isort.cfg index ce6c141e..13919fae 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -4,4 +4,4 @@ line_length = 150 use_parentheses = True multi_line_output = 3 sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER -known_first_party = apify,apify_client, apify_shared +known_first_party = apify,apify_client,apify_shared diff --git a/CHANGELOG.md b/CHANGELOG.md index b75ea5ad..9ea473c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ Changelog ========= +[1.1.2](../../releases/tag/v1.1.2) - 2023-08-01 +----------------------------------------------- + +### Internal changes + +- Import general constants and utilities from [apify-shared](https://github.com/apify/apify-shared-python/) library + [1.1.1](../../releases/tag/v1.1.1) - 2023-05-23 ----------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index 7ee55567..2e138f79 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "apify" -version = "1.1.1" +version = "1.1.2" description = "Apify SDK for Python" readme = "README.md" license = {text = "Apache Software License"} diff --git a/src/apify/consts.py b/src/apify/consts.py index ae3e1f44..e62a6eaa 100644 --- a/src/apify/consts.py +++ b/src/apify/consts.py @@ -1,5 +1,44 @@ import re +import warnings from enum import Enum +from typing import Any + +from apify_shared.consts import BOOL_ENV_VARS as _BOOL_ENV_VARS +from apify_shared.consts import DATETIME_ENV_VARS as _DATETIME_ENV_VARS +from apify_shared.consts import FLOAT_ENV_VARS as _FLOAT_ENV_VARS +from apify_shared.consts import INTEGER_ENV_VARS as _INTEGER_ENV_VARS +from apify_shared.consts import STRING_ENV_VARS as _STRING_ENV_VARS +from apify_shared.consts import ActorEventTypes as _ActorEventTypes +from apify_shared.consts import ActorExitCodes as _ActorExitCodes +from apify_shared.consts import ApifyEnvVars as _ApifyEnvVars + +DEPRECATED_NAMES = [ + 'BOOL_ENV_VARS', + 'DATETIME_ENV_VARS', + 'FLOAT_ENV_VARS', + 'INTEGER_ENV_VARS', + 'STRING_ENV_VARS', + 'ActorEventTypes', + 'ActorExitCodes', + 'ApifyEnvVars', +] + + +# The following piece of code is highly inspired by the example in https://peps.python.org/pep-0562. +# The else branch is missing intentionally! Check the following discussion for details: +# https://github.com/apify/apify-client-python/pull/132#discussion_r1277294315. +def __getattr__(name: str) -> Any: + if name in DEPRECATED_NAMES: + warnings.warn( + ( + f'Importing "{name}" from "apify_client.consts" is deprecated and will be removed in the future. ' + 'Please use "apify_shared" library instead.' + ), + category=DeprecationWarning, + stacklevel=2, + ) + return globals()[f'_{name}'] + raise AttributeError(f'module {__name__!r} has no attribute {name!r}') class _StorageTypes(str, Enum): diff --git a/tests/integration/test_actor_api_helpers.py b/tests/integration/test_actor_api_helpers.py index 8d096bbc..e5d8b245 100644 --- a/tests/integration/test_actor_api_helpers.py +++ b/tests/integration/test_actor_api_helpers.py @@ -235,7 +235,7 @@ class TestActorAbort: async def test_actor_abort(self, make_actor: ActorFactory) -> None: async def main_inner() -> None: async with Actor: - await asyncio.sleep(60) + await asyncio.sleep(120) # This should not be set, the actor should be aborted by now await Actor.set_value('OUTPUT', 'dummy')