refactor!: Introduce fully typed clients [WIP]#554
Conversation
e470329 to
64a173b
Compare
64a173b to
c410e21
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #554 +/- ##
===========================================
+ Coverage 75.92% 95.20% +19.28%
===========================================
Files 42 44 +2
Lines 2471 4586 +2115
===========================================
+ Hits 1876 4366 +2490
+ Misses 595 220 -375
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
39bc762 to
894685c
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces fully typed API clients with Pydantic models generated from OpenAPI specifications. It represents a major architectural refactoring to improve type safety and developer experience.
Changes:
- Generates Pydantic models from OpenAPI specs using datamodel-code-generator
- Refactors HTTP client architecture into modular, well-structured components
- Introduces comprehensive type annotations across all client methods
- Adds new integration tests for webhooks, schedules, user operations, store, and more
- Removes dependency on apify-shared and adds pydantic as core dependency
Reviewed changes
Copilot reviewed 94 out of 97 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Adds pydantic dependency, configures datamodel-code-generator, removes apify-shared |
| src/apify_client/_config.py | New immutable configuration dataclass for client settings |
| src/apify_client/_consts.py | New constants and enums (ActorJobStatus, WebhookEventType, etc.) |
| src/apify_client/_statistics.py | Renames Statistics to ClientStatistics |
| src/apify_client/_http_clients/ | Refactored HTTP client into modular sync/async/base structure |
| src/apify_client/errors.py | Improved error handling and docstrings |
| src/apify_client/_logging.py | Reorganized logging infrastructure |
| src/apify_client/_resource_clients/ | Complete refactor with typed responses |
| tests/unit/ | Updated unit tests for renamed classes and new structure |
| tests/integration/ | New comprehensive integration tests |
| docs/, website/ | Updated examples to use typed models |
| scripts/ | Updated for new file structure |
Comments suppressed due to low confidence (1)
src/apify_client/_resource_clients/key_value_store.py:854
- This assignment to 'keys_public_url' is unnecessary as it is redefined before this value is used.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Reflects OpenAPI spec changes: - Removed GetOpenApiResponse meta-schema (~40 unnecessary classes) - Removed Folder enum (now simple bool field) Models reduced from ~245 to 203 classes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update all resource clients to use the new standardized response model names after OpenAPI schema refactoring. Changes: - Remove "Get" prefix from all response model imports and usages - Update model names: Get*Response → *Response - Update list model names: GetListOf*Response → ListOf*Response - Consolidated response wrappers now use single names (e.g., ActorResponse instead of separate Create/Get/UpdateActorResponse) Affected clients: - actor, actor_collection - actor_env_var, actor_env_var_collection - actor_version, actor_version_collection - build, build_collection - dataset, dataset_collection - key_value_store, key_value_store_collection - request_queue, request_queue_collection - run, run_collection - schedule, schedule_collection - store_collection - task, task_collection - user - webhook, webhook_collection, webhook_dispatch Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Regenerated from updated OpenAPI specs that removed: - MonthlyUsageCycle (now uses UsageCycle) - CreateOrUpdateEnvVarRequest (now uses EnvVar) This removes the duplicate Python classes from the generated models. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
ListOfSchedules and ListOfStoreActors now extend PaginationResponse instead of duplicating the pagination fields. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
BuildsMeta.client_ip now uses `str | None` instead of `IPv4Address | None`, matching RunMeta and supporting both IPv4 and IPv6 addresses. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
BuildsMeta.origin now uses the RunOrigin enum instead of a plain string, matching the type used by RunMeta.origin. This improves type safety and consistency across the codebase. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- WebhookDispatch.status now uses WebhookDispatchStatus enum - WebhookDispatch.event_type now uses WebhookEventType enum - ExampleWebhookDispatch.status now uses WebhookDispatchStatus enum - New WebhookDispatchStatus enum added (SUCCEEDED, FAILED) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- ScheduleAction.type now uses ScheduleActionType enum - ScheduleActions.type now uses ScheduleActionType enum - ScheduleCreateActions.type now uses ScheduleActionType enum - New ScheduleActionType enum added (RUN_ACTOR, RUN_ACTOR_TASK) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
closing in favor of #604 |
This PR introduces fully typed API clients, with models generated directly from OpenAPI specifications.
Description
pyproject.tomland theMakefile.apify/apify-docsfor details - fix(openapi): Fix OpenApi specification apify-docs#2169.apify/apify-sdk-pythonfor details - chore: Adapt to apify-client v3 [WIP] apify-sdk-python#719.Issues
Testing