Open raratiru opened 1 year ago
[ ] bump-pydantic auto-upgrades some pydantic v1 code to pydantic v2
pip install bump-pydantic
bump-pydantic pydantic_schemaorg/
bump-pydantic src/
[ ] sed-replace pydantic imports
The Pydantic V2 package also continues to provide access to the Pydantic V1 API by importing through pydantic.v1.
For example, you can use the BaseModel class from Pydantic V1 instead of the Pydantic V2 pydantic.BaseModel class:
from pydantic.v1 import BaseModel
git status; # git stash || git commit -a -m
sed -i -e 's/pydantic.BaseModel/pydantic.v1.BaseModel/g' \
-e 's/pydantic.fields/pydantic.v1.fields/g' \
-e 's/from pydantic import fields/from pydantic.v1 import fields/g' \
-e 's/from pydantic import BaseModel/from pydantic.v1 import BaseModel/g'
git diff
grep -rni BaseModel
grep -rni 'from pydantic import' | grep -E 'BaseModel|fields'
grep -rni 'from pydantic import' | grep -E 'validators'
pydantic v1 -> v2 migration guide: https://docs.pydantic.dev/latest/migration/
A new major release of pydantic is published.
There is a migration guide too:
https://docs.pydantic.dev/latest/migration/
Will there be an upgrade or will pull requests be accepted?