-
Notifications
You must be signed in to change notification settings - Fork 16
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
support pydantic v2 #413
support pydantic v2 #413
Conversation
Also supports pydantic v1. pydantic v2 provides v1 api through `pydantic.v1` import, so we can support both versions by trying to import from `pydantic.v1` and fallback to old behaviour. See https://docs.pydantic.dev/latest/migration/#continue-using-pydantic-v1-features. pydantic == 2.0.0 does not work due to pydantic/pydantic#6361, so we need to blacklist that specific version.
@@ -41,11 +41,13 @@ class Config: | |||
|
|||
def assert_type(self, name): | |||
assert_name_is_valid(name) | |||
# pylint: disable-next=unsupported-membership-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the following is needed due to a false-positive with pylint. It's looking at above = None
default value and raising a false-positive.
@skshetry is there a reason to support both? |
Studio still relies on MLEM and therefore on Pydantic v1. Also I did not want to block any DVC users that are using pydantic v2 (or, pydantic v1 even). Also, using pydantic v2 APIs means changing code, whereas if we use v1 APIs for now, we can support both and is working perfectly fine. |
sounds good. can we run tests with both then? |
I consider pydantic v1 support as best effort from now on. I don’t think we need to test both. |
sound good, I think Studio has enough tests to detect failure if there is a regression in pydantic v1 |
Also supports pydantic v1.
pydantic v2 provides v1 api through
pydantic.v1
import, so we can support both versions by trying to import frompydantic.v1
and fallback to old behaviour.See https://docs.pydantic.dev/latest/migration/#continue-using-pydantic-v1-features.
pydantic == 2.0.0 does not work due to pydantic/pydantic#6361, so we need to blacklist that specific version.