-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Working with Pydantic v1 while having v2 installed #10360
Comments
In case it helps, I started PR about that: |
This comment was marked as spam.
This comment was marked as spam.
Repository owner
locked as spam and limited conversation to collaborators
Oct 3, 2023
Closed
1 task
5 tasks
5 tasks
14 tasks
5 tasks
Repository owner
unlocked this conversation
Apr 11, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Discussed in #9966
Originally posted by slafs July 29, 2023
This is a continuation of a topic introduced in #9709 (comment) as requested by @Kludex. I've chosen the "Show and tell" category as the (lack of) template seems better for this discussion.
In the original thread I've asked if there's a way to work with pydantic v1 while having v2 installed:
Pydantic v2 ships the latest version of v1 for easier migration, so the pattern is to work with v1 via things like
from pydantic.v1 import BaseModel
etc. while having v2 installed.Currently, this approach doesn't seem to work with FastAPI 0.100.0 and the following snippet:
produces the following error:
Switching from
pydantic.v1
to justpydantic
(v2) obviously works.I'm seeing there's
fastapi._compat
module andPYDANTIC_V2
var, but I'm not sure if that's the right direction.For reference, installed versions:
Now... that being said, I'm not even sure if this would be helpful to anyone even if FastAPI did support it. My initial thought was that this would ease the migration, but the reality seems more complicated. E.g. models are used by other models and even Pydantic itself doesn't support mixing v1 and v2 together. So given that the cost of figuring out the plan for the gradual migration seems comparable with doing the whole migration at once (at least for us).
Maybe it would be useful if people commented on their intended use case and see if that's actually a feature that's needed/wanted.
The text was updated successfully, but these errors were encountered: