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

Support for both Pydantic V1 and V2 #38

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

khalo-sa
Copy link

Hi @phillipdupuis,
after switching to Pydantic V2 in one of my projects, this library stopped working.
To make sure that my changes are compatible with both, Pydantic V1 and V2, I created two virtual environments with each respective Pydantic version, and this library installed.
The initial goal was to keep the tests the same, but V2 requires slight adjustments to the inputs and generated outputs, which is why I created v1/v2-subdirectories for each type of test.
The changes that made that necessary were:

The library seems to work now with both, V1 and V2, by dynamically determining the installed Pydantic version and using the appropriate functions.

@khalo-sa khalo-sa changed the title Pydantic V2 support Support for both Pydantic V1 and V2 Jul 28, 2023
@khalo-sa
Copy link
Author

khalo-sa commented Aug 9, 2023

I just added support for computed fields, and a corresponding test.

@nick-somebody
Copy link

Just looking through pydantic docs. https://docs.pydantic.dev/latest/version-policy/#pydantic-v1

Active development of V1 has already stopped, however critical bug fixes and security vulnerabilities will be fixed in V1 for one year after the release of V2 (June 30, 2024).

The complexity of supporting both versions seems excessive to me. Wouldn't this library be better just releasing a v2 with support for pydantic v2?

Any reason I'm missing for supporting both pydantic major versions?

@akx
Copy link

akx commented Dec 21, 2023

Any reason I'm missing for supporting both pydantic major versions?

There's a lot of Pydantic 1 using code out there that's not necessarily going to update, but could use this library. It doesn't seem to be very much extra code to support both (the majority of this PR's changes are test fixtures).

@nick-somebody
Copy link

Any reason I'm missing for supporting both pydantic major versions?

There's a lot of Pydantic 1 using code out there that's not necessarily going to update, but could use this library. It doesn't seem to be very much extra code to support both (the majority of this PR's changes are test fixtures).

@akx pydantic 1 using code can use v1 of this library right?

@voidus
Copy link

voidus commented Jan 12, 2024

What's the difference between this PR and #40 or #37 ?

Can they be consolidated?

@atodniAr
Copy link

atodniAr commented May 6, 2024

In my project this MR worked. I'm using pydantic 2.6.4.
#40 failed. I haven't try #37

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.

None yet

5 participants