fix: handle both pydantic version 1 and 2 to support python 3.14#101
Open
ghmeier wants to merge 1 commit intoexplosion:mainfrom
Open
fix: handle both pydantic version 1 and 2 to support python 3.14#101ghmeier wants to merge 1 commit intoexplosion:mainfrom
ghmeier wants to merge 1 commit intoexplosion:mainfrom
Conversation
As of python 3.14, pydantic>=2.0.0 does not work with the pydantic.v1 namespace. To fix this without a major version upgrade, I added some conditional model definitions where necessary. The main breaking changes impacting this repo are pretty straightforward, just changing root_validator to model_validator, altering the model configration to use a dictionary, and swapping to pattern over regex for string fields. I've also updated CI to test against python 3.14.
|
So many projects are suffering because of the pydantic 2 changes, I hope those manage to restore Python 3.14 support before 3.15 arrives 😞 Is this workaround ready to be reviewed and merged? |
Author
|
@reneleonhardt - from my perspective it is. If it's amenable to the maintainers, it's probably less complicated and hacky to just make a major version bump, swap over to requiring pydantic>=2.0.0 entirely. Since this library doesn't seem to have very frequent impactful updates, maybe that'd work out ok! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
As of python 3.14, pydantic>=2.0.0 does not work with the pydantic.v1 namespace. While trying to fix this same issue for spaCy (explosion/spaCy#13895), I ran into this library also throwing errors from the old pydantic version.
To fix this without a major version upgrade, I added some conditional model definitions where necessary. I think this approach is fairly safe since pydantic appears to only be used internally to validate configuration so you shouldn't have to worry about any other packages calling deprecated pydantic model functions. I saw a similar pattern from one of y'alls other repos here: explosion/confection#31
The main pydantic breaking changes impacting this repo are pretty straightforward, just changing root_validator to model_validator, altering the model configration to use a dictionary, and swapping to pattern over regex for string fields.
I've also updated CI to test against python 3.14.
On my own, I've run tests against back to python 3.8 with
pydantic==1.7.4.Types of change
Bug fix - the package is broken on python 3.14 and breaks any upstream packages that attempt to use python 3.14.
Checklist