Skip to content

refactor: Use Pydantic models instead of custom dict representations#650

Merged
vdusek merged 5 commits intomasterfrom
refactor/pydantic-request-models
Feb 27, 2026
Merged

refactor: Use Pydantic models instead of custom dict representations#650
vdusek merged 5 commits intomasterfrom
refactor/pydantic-request-models

Conversation

@vdusek
Copy link
Contributor

@vdusek vdusek commented Feb 25, 2026

Summary

  • Replace hand-written _representations.py helper functions (302 lines deleted) with Pydantic request models (UpdateActorRequest, ScheduleCreate, WebhookCreate, WebhookUpdate, etc.) for constructing API payloads.
  • Simplify _update() / _create() in ResourceClient to accept **kwargs and use a new _clean_json_payload() static method on ResourceClientBase instead of the removed filter_none_values() utility.
  • Remove unused enum_to_value() and filter_none_values() from _utils.py — Pydantic serialization handles enum conversion and None filtering.
  • Add populate_by_name=True to all generated Pydantic model configs via datamodel-codegen configuration, so models can be initialized using either snake_case field names or camelCase aliases.
  • Models had to be adjusted, see PR to apify-docs - fix(openapi): Update OpenAPI schemas to match API behaviour apify-docs#2291.

Test plan

  • CI passes

🤖 Generated with Claude Code

@vdusek vdusek added adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels Feb 25, 2026
@vdusek vdusek self-assigned this Feb 25, 2026
@github-actions github-actions bot added this to the 135th sprint - Tooling team milestone Feb 25, 2026
@github-actions github-actions bot added the tested Temporary label used only programatically for some analytics. label Feb 25, 2026
@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.52%. Comparing base (5ae33a0) to head (f2133a4).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #650      +/-   ##
==========================================
- Coverage   96.59%   96.52%   -0.07%     
==========================================
  Files          46       45       -1     
  Lines        4433     4318     -115     
==========================================
- Hits         4282     4168     -114     
+ Misses        151      150       -1     
Flag Coverage Δ
integration 94.55% <100.00%> (-0.10%) ⬇️
unit 78.04% <80.90%> (+1.52%) ⬆️

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 changed the title refactor!: Use Pydantic request models and simplify base client internals refactor: Use Pydantic request models and simplify base client internals Feb 25, 2026
@vdusek vdusek changed the title refactor: Use Pydantic request models and simplify base client internals refactor: Use Pydantic models instead of custom dict representations Feb 25, 2026
@vdusek vdusek force-pushed the refactor/pydantic-request-models branch from 1b03bbc to 36d710a Compare February 27, 2026 09:13
@vdusek vdusek marked this pull request as ready for review February 27, 2026 09:18
vdusek added a commit to apify/apify-docs that referenced this pull request Feb 27, 2026
These changes align the OpenAPI specs with the Pydantic models generated
for apify-client-python (PR apify/apify-client-python#650), so that
`datamodel-codegen` produces matching output without manual edits.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vdusek vdusek requested a review from Pijukatel February 27, 2026 09:51
vdusek added a commit to apify/apify-docs that referenced this pull request Feb 27, 2026
## Summary

- Adds missing `ActorStandby` schema, missing fields (`actorStandby`,
`exampleRunInput`, `isDeprecated`, `title`, `maxItems`,
`forcePermissionLevel`), and removes incorrect `required` constraints
from request schemas.
- Cleans up `UpdateTaskRequest` to only contain mutable fields (removes
read-only fields like `id`, `userId`, `createdAt`, etc.).

## Related PRs

- apify/apify-client-python#650

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@vdusek vdusek merged commit 41aa9aa into master Feb 27, 2026
24 checks passed
@vdusek vdusek deleted the refactor/pydantic-request-models branch February 27, 2026 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants