🔊 Add deprecation warnings when using pydantic.v1 (#14583)

This commit is contained in:
Sebastián Ramírez
2025-12-21 08:44:10 -08:00
committed by GitHub
parent 6513d4daa1
commit 6e42bcd8ce
20 changed files with 756 additions and 556 deletions

View File

@@ -1,3 +1,4 @@
import warnings
from datetime import datetime, timezone
from fastapi import FastAPI
@@ -48,9 +49,12 @@ def test_pydanticv1():
app = FastAPI()
model = ModelWithDatetimeField(dt_field=datetime(2019, 1, 1, 8))
@app.get("/model", response_model=ModelWithDatetimeField)
def get_model():
return model
with warnings.catch_warnings(record=True):
warnings.simplefilter("always")
@app.get("/model", response_model=ModelWithDatetimeField)
def get_model():
return model
client = TestClient(app)
with client: