-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
Migrate to Pydantic V2 #1115
Comments
Hi, Is there any progress ? Since FastApi has just released ther version 0.100.0 with pydantic v2 |
Very interested in this. Have tried looking at creating a PR myself with the upgrade, however it is definitely not a trivial task. |
I've looked through ormar's code and pydantic's upgrade guide and many things used by ormar were removed without any alternative. |
To save a little time for whoever else wants to start working on this: See also #1151. Since Pydantic V2 retains the V1 API in a separate namespace git grep -l 'from pydantic' | xargs sed -i -e 's/^from pydantic/from pydantic.v1/'
git grep -l '^import pydantic$' | xargs sed -i -e 's/^import pydantic$/import pydantic.v1 as pydantic/' Which leaves only 19 errors in This, in turn, looks related to fastapi/fastapi#9966: FastAPI, as of version 0.100.1, sets in This does not work, because FastAPI apparently sets up things at import time: from fastapi import FastAPI
import pydantic.version as pydantic_version
pydantic_version.VERSION = '1.999' But neither does this, because FastAPI has import pydantic.version as pydantic_version
pydantic_version.VERSION = '1.999'
from fastapi import FastAPI So where to go from here?
|
The problem is, that's, as you've already said, a quick and dirty fix and nothing for the long run. |
It's true that a lot of methods and logic was changed and was removed but when I started to check a lot of them are replaceable by something else, not sure yet if all of them but after all functionality wise the new version of pydantic covers most if not all of the previous use cases. There will be some breaking changes for sure as now config is a dict and not a inner class etc. The change scope is big so it will take time but I will try to port it to V2, will see if possible. |
Some great news! I really appreciate your response right here! Please keep us up to datea and many thanks again for this awesome library! |
News? |
I like ormar very much, but because my project uses pydantic2, I have to choose other orm frameworks. I hope that the development team of ormar can support pydantic2 as soon as possible. I hope that ormar will get better and better |
@hezhaozhao-git which orm has support for pydantic v2? |
I haven't tried myself, but it seems that the most unique pydantic features can be bumped with this tool: https://github.com/pydantic/bump-pydantic I'm not sure if they handle init and similar stuff not supported in pydantic v2, but I would try this. |
Are there any news about using pydanticV2 in ormar? I am forced to use sqlachelmy with pydanticV2, but I would like to use something different |
You can try version 0.20.0 |
@collerek You're awesome, thank you! |
Pydantic V2 changes the API and is already in beta. A migration would be necessary, especially when FastAPI will require Pydantic V2 and ormar V1. Here's the link to the migration guide: https://docs.pydantic.dev/dev-v2/migration/
The text was updated successfully, but these errors were encountered: