Background
We're on Pydantic ≥2.11. src/apify_client/_models.py is generated by datamodel-codegen: ~190 models with ~606 explicit Field(alias='camelCase') entries, e.g.:
source_type: Annotated[VersionSourceType | None, Field(alias='sourceType')] = None
is_public: Annotated[bool, Field(alias='isPublic', examples=[False])] = None
All models already share ConfigDict(extra='allow', populate_by_name=True).
Proposal
Drive the codegen so each model's config carries alias_generator=to_camel, and emit an explicit alias only where the conversion is irregular:
from pydantic.alias_generators import to_camel
model_config = ConfigDict(extra='allow', populate_by_name=True, alias_generator=to_camel)
Where it makes sense
Because this file is generated, the work lives in the generation + postprocess pipeline rather than in hand edits:
- Irregular conversions still need an explicit alias. The existing override in
datamodel_codegen_aliases.json (gitHubGistUrl → github_gist_url) is a good example: to_camel('github_gist_url') yields githubGistUrl, not gitHubGistUrl, so such overrides must win over the generator.
scripts/postprocess_generated_models.py builds its alias map by AST-walking Field(alias=...) to synthesize the camelCase *Dict TypedDict variants. If aliases stop being emitted per field, that step must instead derive them via to_camel plus the override map. This is the main thing to verify.
Scope
Refactor only, smaller generated output. The wire format must stay identical, guarded by tests.
Background
We're on Pydantic ≥2.11.
src/apify_client/_models.pyis generated by datamodel-codegen: ~190 models with ~606 explicitField(alias='camelCase')entries, e.g.:All models already share
ConfigDict(extra='allow', populate_by_name=True).Proposal
Drive the codegen so each model's config carries
alias_generator=to_camel, and emit an explicit alias only where the conversion is irregular:Where it makes sense
Because this file is generated, the work lives in the generation + postprocess pipeline rather than in hand edits:
datamodel_codegen_aliases.json(gitHubGistUrl→github_gist_url) is a good example:to_camel('github_gist_url')yieldsgithubGistUrl, notgitHubGistUrl, so such overrides must win over the generator.scripts/postprocess_generated_models.pybuilds its alias map by AST-walkingField(alias=...)to synthesize the camelCase*DictTypedDict variants. If aliases stop being emitted per field, that step must instead derive them viato_camelplus the override map. This is the main thing to verify.Scope
Refactor only, smaller generated output. The wire format must stay identical, guarded by tests.