poetry: bump datamodel-code-generator from 0.26.1 to 0.53.0
Open
Number: #1127
Type: Pull Request
State: Open
Type: Pull Request
State: Open
Author:
dependabot[bot]
Association: Unknown
Comments: 2
Association: Unknown
Comments: 2
Created:
February 02, 2026 at 01:45 AM UTC
(4 months ago)
(4 months ago)
Updated:
February 02, 2026 at 01:50 AM UTC
(4 months ago)
(4 months ago)
Labels:
dependencies python
dependencies python
Description:
Bumps datamodel-code-generator from 0.26.1 to 0.53.0.
Release notes
Sourced from datamodel-code-generator's releases.
0.53.0
Breaking Changes
Custom Template Update Required
- Parser subclass signature change - The
Parserbase class now requires two generic type parameters:Parser[ParserConfigT, SchemaFeaturesT]instead of justParser[ParserConfigT]. Custom parser subclasses must be updated to include the second type parameter. (#2929)# Before class MyCustomParser(Parser["MyParserConfig"]): ... # After class MyCustomParser(Parser["MyParserConfig", "JsonSchemaFeatures"]): ...- New abstract
schema_featuresproperty required - Custom parser subclasses must now implement theschema_featuresabstract property that returns aJsonSchemaFeatures(or subclass) instance. (#2929)from functools import cached_property from datamodel_code_generator.parser.schema_version import JsonSchemaFeatures from datamodel_code_generator.enums import JsonSchemaVersion class MyCustomParser(Parser["MyParserConfig", "JsonSchemaFeatures"]): @cached_property def schema_features(self) -> JsonSchemaFeatures: return JsonSchemaFeatures.from_version(JsonSchemaVersion.Draft202012)- Parser
_create_default_configrefactored to use class variable - Subclasses that override_create_default_configshould now set the_config_class_nameclass variable instead. The base implementation uses this variable to dynamically instantiate the correct config class. (#2929)# Before @classmethod def _create_default_config(cls, options: MyConfigDict) -> MyParserConfig: # custom implementation... # After _config_class_name: ClassVar[str] = "MyParserConfig" # No need to override _create_default_config if using standard config creation- Template condition for default values changed - If you use custom Jinja2 templates based on
BaseModel_root.jinja2orRootModel.jinja2, the condition for including default values has changed fromfield.requiredto(field.required and not field.has_default). Update your custom templates if you override these files. (#2960)Code Generation Changes
- RootModel default values now included in generated code - Previously, default values defined in JSON Schema or OpenAPI specifications for root models were not being applied to the generated Pydantic code. Now these defaults are correctly included. For example, a schema defining a root model with
default: 1will generate__root__: int = 1(Pydantic v1) orroot: int = 1(Pydantic v2) instead of just__root__: intorroot: int. This may affect code that relied on the previous behavior where RootModel fields had no default values. (#2960)- Required fields with list defaults now use
default_factory- Previously, required fields with list-type defaults (like__root__: list[ID] = ['abc', 'efg']) were generated with direct list assignments. Now they correctly useField(default_factory=lambda: ...)which follows Python best practices for mutable defaults. This changes the structure of generated code for root models and similar patterns with list defaults. (#2958) Before:After:class Family(BaseModel): __root__: list[ID] = ['abc', 'efg']class Family(BaseModel):
... (truncated)
Changelog
Sourced from datamodel-code-generator's changelog.
0.53.0 - 2026-01-12
Breaking Changes
Custom Template Update Required
- Parser subclass signature change - The
Parserbase class now requires two generic type parameters:Parser[ParserConfigT, SchemaFeaturesT]instead of justParser[ParserConfigT]. Custom parser subclasses must be updated to include the second type parameter. (#2929)# Before class MyCustomParser(Parser["MyParserConfig"]): ... # After class MyCustomParser(Parser["MyParserConfig", "JsonSchemaFeatures"]): ...- New abstract
schema_featuresproperty required - Custom parser subclasses must now implement theschema_featuresabstract property that returns aJsonSchemaFeatures(or subclass) instance. (#2929)from functools import cached_property from datamodel_code_generator.parser.schema_version import JsonSchemaFeatures from datamodel_code_generator.enums import JsonSchemaVersion class MyCustomParser(Parser["MyParserConfig", "JsonSchemaFeatures"]): @cached_property def schema_features(self) -> JsonSchemaFeatures: return JsonSchemaFeatures.from_version(JsonSchemaVersion.Draft202012)- Parser
_create_default_configrefactored to use class variable - Subclasses that override_create_default_configshould now set the_config_class_nameclass variable instead. The base implementation uses this variable to dynamically instantiate the correct config class. (#2929)# Before @classmethod def _create_default_config(cls, options: MyConfigDict) -> MyParserConfig: # custom implementation... # After _config_class_name: ClassVar[str] = "MyParserConfig" # No need to override _create_default_config if using standard config creation- Template condition for default values changed - If you use custom Jinja2 templates based on
BaseModel_root.jinja2orRootModel.jinja2, the condition for including default values has changed fromfield.requiredto(field.required and not field.has_default). Update your custom templates if you override these files. (#2960)Code Generation Changes
- RootModel default values now included in generated code - Previously, default values defined in JSON Schema or OpenAPI specifications for root models were not being applied to the generated Pydantic code. Now these defaults are correctly included. For example, a schema defining a root model with
default: 1will generate__root__: int = 1(Pydantic v1) orroot: int = 1(Pydantic v2) instead of just__root__: intorroot: int. This may affect code that relied on the previous behavior where RootModel fields had no default values. (#2960)- Required fields with list defaults now use
default_factory- Previously, required fields with list-type defaults (like__root__: list[ID] = ['abc', 'efg']) were generated with direct list assignments. Now they correctly useField(default_factory=lambda: ...)which follows Python best practices for mutable defaults. This changes the structure of generated code for root models and similar patterns with list defaults. (#2958) Before:After:class Family(BaseModel): __root__: list[ID] = ['abc', 'efg']
... (truncated)
Commits
a6a7b04Fix bug in handling of graphql empty list defaults (#2948)838b2a0Fix array RootModel default value handling in parser (#2963)e717208Fix allOf array property merging to preserve child $ref (#2962)ae89a00Add GenerateConfig lazy import from top-level module (#2961)88c7fe4Fix required list fields ignoring empty default values (#2958)4cbf3bfFix RootModel default value not being applied (#2960)aa088d6Add --use-closed-typed-dict option to control PEP 728 TypedDict generation (#...98f3a48Fix IndexError when using --reuse-scope=tree with single file output (#2954)fa1fc11fix: move UnionMode import outside TYPE_CHECKING for Pydantic runtime… (#2950)4decf36Add comprehensive feature metadata to schema version dataclasses (#2946)- Additional commits viewable in compare view
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebasewill rebase this PR@dependabot recreatewill recreate this PR, overwriting any edits that have been made to it@dependabot mergewill merge this PR after your CI passes on it@dependabot squash and mergewill squash and merge this PR after your CI passes on it@dependabot cancel mergewill cancel a previously requested merge and block automerging@dependabot reopenwill reopen this PR if it is closed@dependabot closewill close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot show <dependency name> ignore conditionswill show all of the ignore conditions of the specified dependency@dependabot ignore this major versionwill close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor versionwill close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependencywill close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Package Dependencies
Technical Details
| ID: | 13380483 |
| UUID: | 3883524597 |
| Node ID: | PR_kwDOHvKt1c7AyjDH |
| Host: | GitHub |
| Repository: | NHSDigital/NRLF |