From 0fadb925c0d4121d244541d4c4140d3f40b72970 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Wed, 25 Feb 2026 16:01:12 +0100 Subject: [PATCH] refactor: Remove internal models module in favor of generated models ActorJob and ActorJobResponse schemas were added to the OpenAPI spec (apify/apify-docs#XXXX), so they are now generated into _models.py. This removes the manually maintained _internal_models.py module. Co-Authored-By: Claude Opus 4.6 --- src/apify_client/_internal_models.py | 29 ------------------- src/apify_client/_models.py | 25 ++++++++++++++-- .../_resource_clients/_resource_client.py | 2 +- 3 files changed, 24 insertions(+), 32 deletions(-) delete mode 100644 src/apify_client/_internal_models.py diff --git a/src/apify_client/_internal_models.py b/src/apify_client/_internal_models.py deleted file mode 100644 index 4d44cb5e..00000000 --- a/src/apify_client/_internal_models.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Internal Pydantic models that are not part of the public API and are therefore not generated.""" - -from __future__ import annotations - -from pydantic import BaseModel, ConfigDict - -from apify_client._models import ActorJobStatus # noqa: TC001 - - -class ActorJob(BaseModel): - """Minimal model for an Actor job (run or build) with status. - - Used for validation during polling operations. Allows extra fields so the full response data is preserved. - """ - - model_config = ConfigDict(extra='allow') - - status: ActorJobStatus - - -class ActorJobResponse(BaseModel): - """Response wrapper for an Actor job (run or build). - - Used for minimal validation during polling operations. Allows extra fields so the full response data is preserved. - """ - - model_config = ConfigDict(extra='allow') - - data: ActorJob diff --git a/src/apify_client/_models.py b/src/apify_client/_models.py index 26231768..c9d3127e 100644 --- a/src/apify_client/_models.py +++ b/src/apify_client/_models.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: -# filename: https://docs.apify.com/api/openapi.json -# timestamp: 2026-02-24T08:34:43+00:00 +# filename: openapi.json +# timestamp: 2026-02-25T14:54:37+00:00 from __future__ import annotations @@ -2884,3 +2884,24 @@ class UpdateLimitsRequest(BaseModel): Apify securely stores your ten most recent Actor runs indefinitely, ensuring they are always accessible. Unnamed storages and other Actor runs are automatically deleted after the retention period. If you're subscribed, you can change it to keep data for longer or to limit your usage. [Lear more](https://docs.apify.com/platform/storage/usage#data-retention). """ + + +class ActorJob(BaseModel): + """Minimal model for an Actor job (run or build) with status. Used for validation during polling operations.""" + + model_config = ConfigDict( + extra='allow', + ) + status: ActorJobStatus + """ + Current status of the Actor job. + """ + + +class ActorJobResponse(BaseModel): + """Response wrapper for an Actor job (run or build). Used for minimal validation during polling operations.""" + + model_config = ConfigDict( + extra='allow', + ) + data: ActorJob diff --git a/src/apify_client/_resource_clients/_resource_client.py b/src/apify_client/_resource_clients/_resource_client.py index 5f271ee8..9ba50ead 100644 --- a/src/apify_client/_resource_clients/_resource_client.py +++ b/src/apify_client/_resource_clients/_resource_client.py @@ -8,8 +8,8 @@ from apify_client._consts import DEFAULT_WAIT_FOR_FINISH, DEFAULT_WAIT_WHEN_JOB_NOT_EXIST, TERMINAL_STATUSES from apify_client._docs import docs_group -from apify_client._internal_models import ActorJobResponse from apify_client._logging import WithLogDetailsClient +from apify_client._models import ActorJobResponse from apify_client._utils import catch_not_found_or_throw, response_to_dict, to_safe_id, to_seconds from apify_client.errors import ApifyApiError