Skip to content

Commit 41aa9aa

Browse files
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

27 files changed

+683
-849
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ wrap_string_literal = true
206206
snake_case_field = true
207207
use_subclass_enum = true
208208
extra_fields = "allow"
209+
allow_population_by_field_name = true
209210
aliases = "datamodel_codegen_aliases.json"
210211
formatters = ["ruff-check", "ruff-format"]
211212

src/apify_client/_consts.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
DEFAULT_MIN_DELAY_BETWEEN_RETRIES = timedelta(milliseconds=500)
2626
"""Default minimum delay between retries."""
2727

28-
2928
DEFAULT_WAIT_FOR_FINISH = timedelta(seconds=999999)
3029
"""Default maximum wait time for job completion (effectively infinite)."""
3130

0 commit comments

Comments
 (0)