Skip to content

Conversation

@vdusek
Copy link
Contributor

@vdusek vdusek commented Dec 10, 2025

This PR introduces fully typed API clients, with models generated directly from OpenAPI specifications.

Description

Issues

Testing

  • Add "easy win" additional integration tests, but avoid complex workflows (e.g. Actor creation, execution, and waiting for completion - these things are still being tested only from the SDK).

@vdusek vdusek self-assigned this Dec 10, 2025
@vdusek vdusek added the t-tooling Issues with this label are in the ownership of the tooling team. label Dec 10, 2025
@github-actions github-actions bot added this to the 129th sprint - Tooling team milestone Dec 10, 2025
@vdusek vdusek changed the title refactor!: Add fully typed clients refactor!: Introduce fully typed clients [WIP] Dec 10, 2025
@vdusek vdusek force-pushed the typed-clients branch 2 times, most recently from e470329 to 64a173b Compare December 17, 2025 12:18
@codecov
Copy link

codecov bot commented Dec 19, 2025

Codecov Report

❌ Patch coverage is 94.05561% with 124 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.20%. Comparing base (6210e80) to head (6421151).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...apify_client/_resource_clients/_resource_client.py 83.33% 24 Missing ⚠️
src/apify_client/_resource_clients/run.py 91.60% 11 Missing ⚠️
src/apify_client/_resource_clients/user.py 80.39% 10 Missing ⚠️
src/apify_client/_resource_clients/dataset.py 91.39% 8 Missing ⚠️
.../apify_client/_resource_clients/key_value_store.py 93.54% 8 Missing ⚠️
src/apify_client/_resource_clients/actor.py 93.18% 6 Missing ⚠️
src/apify_client/_resource_clients/schedule.py 88.00% 6 Missing ⚠️
...apify_client/_resource_clients/webhook_dispatch.py 70.00% 6 Missing ⚠️
src/apify_client/_apify_client.py 95.78% 4 Missing ⚠️
...rc/apify_client/_resource_clients/actor_env_var.py 88.88% 4 Missing ⚠️
... and 14 more
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     
Flag Coverage Δ
integration 93.58% <91.70%> (+24.71%) ⬆️
unit 70.60% <50.86%> (+6.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek vdusek force-pushed the typed-clients branch 4 times, most recently from 39bc762 to 894685c Compare January 26, 2026 13:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

vdusek and others added 25 commits January 29, 2026 20:28
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce fully typed Py client Write integration tests

3 participants