-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add pydantic.v1 namespace to Pydantic v1 #9042
Add pydantic.v1 namespace to Pydantic v1 #9042
Conversation
This is my first Pydantic PR so sincere apologies if I'm doing this wrong! I added a very simple test to capture the main functionality. Crucially, the following will not work:
Given that this would be merely a transitional solution to help users move from v1 to v2, I'm not sure the issue is critical, but happy to defer to maintainers. Please review. :) |
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.
Great, thanks! We'll release this change with an upcoming V1 patch (probably next week).
Hi all, this change is useful for things being imported directly like: from pydantic import ... but for imports like: from pydantic.fields import ModelField
from pydantic.generics import GenericModel or: from pydantic import fields
from pydantic import generics it doesn't translate as well. @sydney-runkle would a PR that adds the ability to do these kinds of imports from the |
With pydantic/pydantic#9042 being shipped with [1.10.15](https://docs.pydantic.dev/latest/changelog/#v11015-2024-04-03), we can clean up the imports a bit until we make decisions how to move onward with or without pydantic. --------- Co-authored-by: Steven B. <51370195+sdb9696@users.noreply.github.com>
Change Summary
Following jenshnielsen's brilliant idea in #6022, I added a
pydantic.v1
alias to the v1 version of Pydantic. This will enable cross-version Pydantic support and easier migration of expansive v1 codebases by switching allpydantic
imports topydantic.v1
and removing the upper bound.Fix #6022
Checklist
Selected Reviewer: @hramezani
skip change file check