Skip to content

Conversation

@dependabot
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Jan 13, 2026

Updates the requirements on datamodel-code-generator to permit the latest version.

Release notes

Sourced from datamodel-code-generator's releases.

0.53.0

Breaking Changes

Custom Template Update Required

  • Parser subclass signature change - The Parser base class now requires two generic type parameters: Parser[ParserConfigT, SchemaFeaturesT] instead of just Parser[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_features property required - Custom parser subclasses must now implement the schema_features abstract property that returns a JsonSchemaFeatures (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_config refactored to use class variable - Subclasses that override _create_default_config should now set the _config_class_name class 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.jinja2 or RootModel.jinja2, the condition for including default values has changed from field.required to (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: 1 will generate __root__: int = 1 (Pydantic v1) or root: int = 1 (Pydantic v2) instead of just __root__: int or root: 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 use Field(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:
    class Family(BaseModel):
        __root__: list[ID] = ['abc', 'efg']
    After:
    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 Parser base class now requires two generic type parameters: Parser[ParserConfigT, SchemaFeaturesT] instead of just Parser[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_features property required - Custom parser subclasses must now implement the schema_features abstract property that returns a JsonSchemaFeatures (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_config refactored to use class variable - Subclasses that override _create_default_config should now set the _config_class_name class 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.jinja2 or RootModel.jinja2, the condition for including default values has changed from field.required to (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: 1 will generate __root__: int = 1 (Pydantic v1) or root: int = 1 (Pydantic v2) instead of just __root__: int or root: 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 use Field(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:
    class Family(BaseModel):
        __root__: list[ID] = ['abc', 'efg']
    After:

... (truncated)

Commits
  • a6a7b04 Fix bug in handling of graphql empty list defaults (#2948)
  • 838b2a0 Fix array RootModel default value handling in parser (#2963)
  • e717208 Fix allOf array property merging to preserve child $ref (#2962)
  • ae89a00 Add GenerateConfig lazy import from top-level module (#2961)
  • 88c7fe4 Fix required list fields ignoring empty default values (#2958)
  • 4cbf3bf Fix RootModel default value not being applied (#2960)
  • aa088d6 Add --use-closed-typed-dict option to control PEP 728 TypedDict generation (#...
  • 98f3a48 Fix IndexError when using --reuse-scope=tree with single file output (#2954)
  • fa1fc11 fix: move UnionMode import outside TYPE_CHECKING for Pydantic runtime… (#2950)
  • 4decf36 Add 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 rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will 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 version will 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 dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Updates the requirements on [datamodel-code-generator](https://github.com/koxudaxi/datamodel-code-generator) to permit the latest version.
- [Release notes](https://github.com/koxudaxi/datamodel-code-generator/releases)
- [Changelog](https://github.com/koxudaxi/datamodel-code-generator/blob/main/CHANGELOG.md)
- [Commits](koxudaxi/datamodel-code-generator@0.44.0...0.53.0)

---
updated-dependencies:
- dependency-name: datamodel-code-generator
  dependency-version: 0.53.0
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
@dependabot dependabot bot added dependencies Pull requests that update a dependency file python Pull requests that update Python code labels Jan 13, 2026
@dependabot dependabot bot requested a review from a team as a code owner January 13, 2026 00:30
@dependabot dependabot bot added dependencies Pull requests that update a dependency file python Pull requests that update Python code labels Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants