feat: compatibility with pydantic v2.x.y #8
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.