From e18e931a828c2aa18f4ecdf7f60ed0d8d6ce62b6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Sun, 10 May 2026 04:31:42 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Auto=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastapi/_compat/v2.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fastapi/_compat/v2.py b/fastapi/_compat/v2.py index 78db67b04e..6e5c3f5404 100644 --- a/fastapi/_compat/v2.py +++ b/fastapi/_compat/v2.py @@ -202,7 +202,10 @@ class ModelField: ) -> Any: # What calls this code passes a value that already called # self._type_adapter.validate_python(value) - if polymorphic_serialization and shared.PYDANTIC_VERSION_MINOR_TUPLE < (2, 13): # pragma: no cover + if polymorphic_serialization and shared.PYDANTIC_VERSION_MINOR_TUPLE < ( + 2, + 13, + ): # pragma: no cover raise ValueError( "polymorphic_serialization requires Pydantic >= 2.13. " f"Current version: {shared.PYDANTIC_VERSION}" # type: ignore[attr-defined] # ty: ignore[unused-ignore-comment] @@ -237,7 +240,10 @@ class ModelField: # This uses Pydantic's dump_json() which serializes directly to JSON # bytes in one pass (via Rust), avoiding the intermediate Python dict # step of dump_python(mode="json") + json.dumps(). - if polymorphic_serialization and shared.PYDANTIC_VERSION_MINOR_TUPLE < (2, 13): # pragma: no cover + if polymorphic_serialization and shared.PYDANTIC_VERSION_MINOR_TUPLE < ( + 2, + 13, + ): # pragma: no cover raise ValueError( "polymorphic_serialization requires Pydantic >= 2.13. " f"Current version: {shared.PYDANTIC_VERSION}" # type: ignore[attr-defined] # ty: ignore[unused-ignore-comment]