refactor: derive Pydantic model field aliases with to_camel#950
Open
vdusek wants to merge 2 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #950 +/- ##
==========================================
+ Coverage 87.08% 87.14% +0.06%
==========================================
Files 48 48
Lines 2973 2996 +23
==========================================
+ Hits 2589 2611 +22
- Misses 384 385 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Author
|
Finish this after merging #719 |
d54ef06 to
db193c5
Compare
vdusek
added a commit
that referenced
this pull request
Jun 9, 2026
Split out from #950 (the other half is the `to_camel` alias refactor). Adds concise class and field docstrings to all `@docs_group`-decorated models that were missing them: - `events/_types.py` — `SystemInfoEventData` (8 resource-usage metric fields) and the 8 event wrappers (`name` / `data`). - `_charging.py` — the pricing-info models, plus module-level constant docstrings and a few inline comments converted to docstrings. Also inlines the private `_RelaxedPricingMetadata` mixin into the four pricing subclasses so each documents its own relaxed fields. This is behavior-preserving (field order, aliases, and requiredness are unchanged). This PR keeps the manual field aliases and branches from `master` independently of #950. Once #950 merges, this branch will need a rebase to resolve the overlapping changes in `_charging.py` / `events/_types.py`.
db193c5 to
7d3997c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #949.
Replaces hand-written per-field
Field(alias=...)declarations with Pydantic'salias_generator=to_camel, so each model derives its camelCase JSON aliases from its snake_case field names.Following the existing convention in this repo, the config (
ConfigDict(populate_by_name=True, alias_generator=to_camel, ...)) is repeated per model rather than introduced through a shared base class.Scope
_charging.py— the pricing-info and charge-event models.events/_types.py—SystemInfoEventDataand the event wrapper models.request_loaders/_apify_request_list.py— the request-input models.storage_clients/_apify/_models.py—ApifyKeyValueStoreMetadata,RequestQueueHead,CachedRequest,ApifyRequestQueueMetadata.No breaking change
The generated aliases match the aliases that were declared by hand, so validation and serialization keep the same wire keys. Attribute names are unchanged (
run.usage.actor_compute_unitsand friends still work).The one field whose name differs from its wire key is
RequestQueueHead.lock_time. The API sendslockSecs, whileto_camelwould derivelockTime. It keepsserialization_alias='lockSecs'so it still emitslockSecs, and it now validates from bothlockSecsandlockTimeviaAliasChoices. That change is additive. Nothing that parsed before stops parsing.Configurationis intentionally left untouched. Its fields bind toAPIFY_*/CRAWLEE_*environment variables through validation aliases, so applyingto_camelthere would break env-based configuration.