bauerji / flask-pydantic

flask extension for integration with the awesome pydantic package
MIT License
352 stars 56 forks source link

Support of module pydantic.v1 Since update to Pydantic V2 #90

Open Merinorus opened 6 months ago

Merinorus commented 6 months ago

Hello,

Since the V2 update, Pydantic V2 still includes the V1 models to make the migration easier : https://docs.pydantic.dev/latest/migration/#continue-using-pydantic-v1-features

Example :

 from pydantic.v1 import BaseModel

Unfortunately, it seems flask-pydantic dropped the V1 support when it started to support Pydantic V2 (from version 0.12.0). So, if we have to upgrade, we cannot use the pydantic.v1 legacy models with Flask-Pydantic and we have to migrate the whole project's models to Pydantic V2 models directly. Right?

yctomwang commented 6 months ago

Hi there @Merinorus , yes we have dropped support for pydantic v1, however you can still use the old version on pypi which supports the V1...

Merinorus commented 2 months ago

Hi @yctomwang, So, developers must migrate the whole project in one step whereas they could have the ability to use progressively V2 base models. This is unfortunate because it makes migration much harder from Pydantic V1 to Pydantic V2 in a Flask project.

I opened a PR for this. I could make it work with a Flask project with Pydantic 2.7 and V1 base models. No performance impact should be noticed.