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

Add pydantic v2 support with backwards compatibility #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aaliboyev
Copy link

@aaliboyev aaliboyev commented Aug 15, 2024

Here I tried to add support for pydantic v2 BaseModel and Field.

This solution theoretically (we cover with tests once maintainers approve this implementation) work with any pydantic package.
I tested it with real project and these packages seems to be working with simple Item model.
pydantic<1.10 - Before new BaseModel
pydantic>=1.10.17 - In the migration guide they mention this exact version where they moved old BaseModel under pydantic.v1 namespace

Similarly I tried to move v1 specific adapter and model under pydantic_v1 and used pydantic for new version.
I also tried to include all Field attributes to metadata and of course if some of them don't work fine we can remove or workaround.
If this implementation is acceptable I will try to add some tests and docs. Let me know what we can adjust.

Fixes #72

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.

Pydantic 2 released
1 participant