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

feat: compatibility with pydantic v2.x.y #8

Closed
wants to merge 1 commit into from

Conversation

ddneilson
Copy link
Contributor

What was the problem/requirement? (What/Why)

Pydantic version 2 was released, and contains pydantic v1 as a submodule. This change allows this library to function with both major versions of Pydantic; it will automatically select the v1 submodule if v2 is available in the environment.

What was the solution? (How)

Try to import the v1 module from pydantic v2, and fallback to pydantic v1 if that fails.

What is the impact of this change?

Downstream consumers will be open to use Pydantic V2 at any time without needing to wait for this library to be updated.

How was this change tested?

Using a hatch shell, I ran the test suite with both pydantic v2.3.0 and then again with v1.10.11 installed (via pip install --force).

Was this change documented?

N/A

Is this a breaking change?

No, quite the opposite.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Pydantic version 2 was released, and contains pydantic v1 as a
submodule. This change allows this library to function with both major
versions of Pydantic; it will automatically select the v1 submodule if
v2 is available in the environment.

Signed-off-by: Daniel Neilson <53624638+ddneilson@users.noreply.github.com>
@ddneilson
Copy link
Contributor Author

Closing in favour of an upcoming PR. Pydantic 1.10.17+ contain the pydantic.v1 namespace to make v2 compatibility much easier to do.

@ddneilson ddneilson closed this Oct 28, 2024
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.

1 participant