From 83d55e4f0888abbf3353359779b89c892691827c Mon Sep 17 00:00:00 2001 From: johnslavik Date: Sun, 21 Dec 2025 16:19:30 +0100 Subject: [PATCH] Ignore cases when `v1.BaseModel` is passed when `BaseModel` (v2) is expected --- fastapi/routing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastapi/routing.py b/fastapi/routing.py index 1ca32a237..1bce1770a 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -154,7 +154,7 @@ def _prepare_response_content( exclude_none: bool = False, ) -> Any: if isinstance(res, (may_v1.BaseModel, BaseModel)): - read_with_orm_mode = getattr(_get_model_config(res), "read_with_orm_mode", None) + read_with_orm_mode = getattr(_get_model_config(res), "read_with_orm_mode", None) # type: ignore[arg-type] if read_with_orm_mode: # Let from_orm extract the data from this model instead of converting # it now to a dict. @@ -162,7 +162,7 @@ def _prepare_response_content( # access instead of dict iteration, e.g. lazy relationships. return res return _model_dump( - res, + res, # type: ignore[arg-type] by_alias=True, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults,