Skip to content

Upgrade to pydantic 2#318

Merged
ghidalgo3 merged 7 commits into
mainfrom
guhidalgo/pydanticupgrade
Mar 17, 2025
Merged

Upgrade to pydantic 2#318
ghidalgo3 merged 7 commits into
mainfrom
guhidalgo/pydanticupgrade

Conversation

@ghidalgo3
Copy link
Copy Markdown
Collaborator

@ghidalgo3 ghidalgo3 commented Mar 13, 2025

Description

Dependency constraint upgrade and code changes to support Pydantic > 2. Summary:

  1. In all pyproject.toml files, the pydantic dependency changed from pydantic>=1.9,<2.0.0 to pydantic>=2.0.0 and a new dependency on pydantic-settings added because BaseSettings now comes from that package.
  2. requirements.txt were regenerated
  3. parse_obj -> model_validate
  4. dict(**kwargs) -> model_dump(**kwargs)
  5. class Config: -> model_config : dict
  6. kwarg change: Field(const=True) -> Field(frozen=True)
  7. @validator to either @field_validator or @model_validator
  8. Changed YAML sourced settings to use the settings_customise_sources Pydantic mechanism.
  9. pydantic.error_wrappers.ErrorList -> pydantic_core.ErrorDetails
  10. One instance of changing Union[...] to Annotated[Union[...], Discriminator] to get that discriminated union goodness.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Checklist:

Please delete options that are not relevant.

  • I have performed a self-review
  • Changelog has been updated
  • Documentation has been updated
  • Unit tests pass locally (./scripts/test)
  • Code is linted and styled (./scripts/format)

@ghidalgo3 ghidalgo3 merged commit 3bfa565 into main Mar 17, 2025
@ghidalgo3 ghidalgo3 deleted the guhidalgo/pydanticupgrade branch March 17, 2025 17:23
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

Successfully merging this pull request may close these issues.

1 participant