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

[WIP] Settings model with both pydantic 1 and 2 support #16

Closed
wants to merge 2 commits into from

Conversation

ijpulidos
Copy link
Contributor

Pydantic 2 changed a significant amount of things in the validators. A quick (and dirty?) way of supporting both is using pydantic.v1 import and catching an ImportError exception.

This is still a work in progress and maybe we might consider just sticking with pydantic 1 for now.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (main@40c966b). Click here to learn what that means.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #16   +/-   ##
=======================================
  Coverage        ?   92.18%           
=======================================
  Files           ?        7           
  Lines           ?      422           
  Branches        ?        0           
=======================================
  Hits            ?      389           
  Misses          ?       33           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +10 to +14
# Support for both pydantic 1 and 2
try:
from pydantic.v1 import root_validator
except ImportError:
from pydantic import root_validator
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is what we're doing too everywhere. If we wanted to migrate to v2 only, we'd have to chase upstream to check if anything is v1 only. I haven't had time to check, but I'd guess that OpenFF + QCStack might be a place where there's significant usage of pydantic (and I have no idea if they've prioritised this).

@ijpulidos
Copy link
Contributor Author

Closing this. We will be implementing this in a different way now that this is available https://docs.pydantic.dev/latest/migration/#continue-using-pydantic-v1-features

@ijpulidos ijpulidos closed this Aug 5, 2024
@ijpulidos ijpulidos deleted the pydantic2-support branch August 5, 2024 20:12
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.

3 participants