From 62ca9c87b835ad5d4d413d79a8181d57f674d9e7 Mon Sep 17 00:00:00 2001 From: johnslavik Date: Sun, 21 Dec 2025 15:58:06 +0100 Subject: [PATCH] Restore the previous behavior of `_prepare_response_content` --- fastapi/routing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastapi/routing.py b/fastapi/routing.py index a1f2e44bb..3faac322b 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -29,7 +29,6 @@ from fastapi._compat import ( _model_dump, _normalize_errors, lenient_issubclass, - may_v1, ) from fastapi.datastructures import Default, DefaultPlaceholder from fastapi.dependencies.models import Dependant @@ -58,6 +57,7 @@ from fastapi.utils import ( get_value_or_default, is_body_allowed_for_status_code, ) +from pydantic import BaseModel from starlette import routing from starlette._exception_handler import wrap_app_handling_exceptions from starlette._utils import is_async_callable @@ -152,7 +152,7 @@ def _prepare_response_content( exclude_defaults: bool = False, exclude_none: bool = False, ) -> Any: - if isinstance(res, may_v1.BaseModel): + if isinstance(res, BaseModel): 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