Commit 41aa9aa
authored
refactor: Use Pydantic models instead of custom dict representations (#650)
## 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 -
apify/apify-docs#2291.
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 parent ee07fb4 commit 41aa9aa
File tree
27 files changed
+683
-849
lines changed- src/apify_client
- _resource_clients
- tests/unit
27 files changed
+683
-849
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
| 209 | + | |
209 | 210 | | |
210 | 211 | | |
211 | 212 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| |||
0 commit comments