Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deprecated Pydantic v2 methods #2213

Open
cruisen opened this issue Dec 9, 2024 · 1 comment
Open

Update deprecated Pydantic v2 methods #2213

cruisen opened this issue Dec 9, 2024 · 1 comment

Comments

@cruisen
Copy link

cruisen commented Dec 9, 2024

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.

@riferg206
Copy link

@koxudaxi The unit tests for datamodel_code_generator/parser/jsonschema.py also throw deprecation warnings for the same reasons as above. Should these be updated as well or do they need to stay for backwards compatibility with Pydantic V1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants