dmontagu / fastapi-utils

Reusable utilities for FastAPI
MIT License
1.84k stars 163 forks source link

Add support for Pydantic 2 non-destructively #289

Open frost-nzcr4 opened 3 months ago

frost-nzcr4 commented 3 months ago

I've found implementations here on PR, but they all contain disruptive changes that make Pydentic 2 mandatory or define new functions without tests. I propose to implement this support in a non-destructive and unobtrusive way, while maintaining as much backward compatibility as possible.

All you need is to set extras in fastapi-utils or pin the pydantic dependency in your project:

Tested in my projects with Pydantic v1 on Python 3.10, and Pydantic v2 on Python 3.11 & 3.12.

Fix #276

yuval9313 commented 2 months ago

I liked it very much, however in the new version (soon to be released 0.6.0) we will support pydantic 2.0, leave this around so I can test it to version 1.0