Skip to content

Update deprecated Pydantic v2 methods #2213

@cruisen

Description

@cruisen

The package currently uses several deprecated Pydantic v2 methods that should be updated to their new equivalents:

  1. parse_obj -> model_validate
  2. dict -> model_dump
  3. __fields_set__ -> model_fields_set

These deprecation warnings appear when using the package with Pydantic v2:

  • PydanticDeprecatedSince20: The parse_obj method is deprecated; use model_validate instead.
  • PydanticDeprecatedSince20: The dict method is deprecated; use model_dump instead.
  • PydanticDeprecatedSince20: The fields_set attribute is deprecated, use model_fields_set instead

These methods will be removed in Pydantic v3.0, so they should be updated to ensure future compatibility.

Relevant files:

  • datamodel_code_generator/parser/jsonschema.py

See the Pydantic V2 Migration Guide for more details on the changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions