From 1a9e9a18ace72c48a4af7a6853fc2824e9bfb814 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 8 Oct 2025 17:04:25 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20[pre-commit.ci]=20Auto=20format?= =?UTF-8?q?=20from=20pre-commit.com=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastapi/_compat/v2.py | 1 + fastapi/datastructures.py | 1 - fastapi/encoders.py | 2 +- tests/test_pydantic_v1_v2_multifile/main.py | 1 - 4 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fastapi/_compat/v2.py b/fastapi/_compat/v2.py index 8784d5afc..c5ac1f660 100644 --- a/fastapi/_compat/v2.py +++ b/fastapi/_compat/v2.py @@ -372,6 +372,7 @@ def get_model_fields(model: Type[BaseModel]) -> List[ModelField]: for name, field_info in model.model_fields.items() ] + # Duplicate of several schema functions from Pydantic v1 to make them compatible with # Pydantic v2 and allow mixing the models diff --git a/fastapi/datastructures.py b/fastapi/datastructures.py index 3df81087b..34185b96a 100644 --- a/fastapi/datastructures.py +++ b/fastapi/datastructures.py @@ -11,7 +11,6 @@ from typing import ( ) from fastapi._compat import ( - PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, diff --git a/fastapi/encoders.py b/fastapi/encoders.py index beab3e446..8ff7d58dd 100644 --- a/fastapi/encoders.py +++ b/fastapi/encoders.py @@ -25,7 +25,7 @@ from pydantic.networks import AnyUrl, NameEmail from pydantic.types import SecretBytes, SecretStr from typing_extensions import Annotated, Doc -from ._compat import PYDANTIC_V2, Url, _is_undefined, _model_dump +from ._compat import Url, _is_undefined, _model_dump # Taken from Pydantic v1 as is diff --git a/tests/test_pydantic_v1_v2_multifile/main.py b/tests/test_pydantic_v1_v2_multifile/main.py index d7095b551..90f525bba 100644 --- a/tests/test_pydantic_v1_v2_multifile/main.py +++ b/tests/test_pydantic_v1_v2_multifile/main.py @@ -113,4 +113,3 @@ def handle_v2_list_to_v1_item(data: List[modelsv2.Item]) -> modelsv1.Item: multi=[modelsv1.SubItem(name=s.new_sub_name) for s in item.new_multi], ) return modelsv1.Item(title="", size=0, sub=modelsv1.SubItem(name="")) -