From ec213fa26edc890db62c8692b004c128f3ac200d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Fri, 26 Dec 2025 20:31:38 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Remove=20more=20unused=20referen?= =?UTF-8?q?ces=20to=20Pydantic=20v1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastapi/dependencies/utils.py | 7 +------ fastapi/encoders.py | 2 -- fastapi/routing.py | 30 ------------------------------ 3 files changed, 1 insertion(+), 38 deletions(-) diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py index 088c38130..cbf183774 100644 --- a/fastapi/dependencies/utils.py +++ b/fastapi/dependencies/utils.py @@ -48,7 +48,7 @@ from fastapi.concurrency import ( contextmanager_in_threadpool, ) from fastapi.dependencies.models import Dependant -from fastapi.exceptions import DependencyScopeError, PydanticV1NotSupportedError +from fastapi.exceptions import DependencyScopeError from fastapi.logger import logger from fastapi.security.oauth2 import SecurityScopes from fastapi.types import DependencyCacheKey @@ -318,11 +318,6 @@ def get_dependant( ) continue assert param_details.field is not None - if isinstance(param_details.field, may_v1.ModelField): - raise PydanticV1NotSupportedError( - "pydantic.v1 models are no longer supported by FastAPI." - f" Please update the param {param_name}: {param_details.type_annotation!r}." - ) if isinstance(param_details.field.field_info, params.Body): dependant.body_params.append(param_details.field) else: diff --git a/fastapi/encoders.py b/fastapi/encoders.py index 82ae2f550..453ed463c 100644 --- a/fastapi/encoders.py +++ b/fastapi/encoders.py @@ -234,8 +234,6 @@ def jsonable_encoder( exclude_none=exclude_none, exclude_defaults=exclude_defaults, ) - if "__root__" in obj_dict: - obj_dict = obj_dict["__root__"] return jsonable_encoder( obj_dict, exclude_none=exclude_none, diff --git a/fastapi/routing.py b/fastapi/routing.py index 4568077ef..66e313e6e 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -144,36 +144,6 @@ def websocket_session( return app -def _prepare_response_content( - res: Any, - *, - exclude_unset: bool, - exclude_defaults: bool = False, - exclude_none: bool = False, -) -> Any: - if isinstance(res, list): - return [ - _prepare_response_content( - item, - exclude_unset=exclude_unset, - exclude_defaults=exclude_defaults, - exclude_none=exclude_none, - ) - for item in res - ] - elif isinstance(res, dict): - return { - k: _prepare_response_content( - v, - exclude_unset=exclude_unset, - exclude_defaults=exclude_defaults, - exclude_none=exclude_none, - ) - for k, v in res.items() - } - return res - - def _merge_lifespan_context( original_context: Lifespan[Any], nested_context: Lifespan[Any] ) -> Lifespan[Any]: