From 1828e454d7b4ff01c273e5e786375b98c1f1341f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Thu, 18 Dec 2025 13:40:08 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Do=20not=20import=20Pydantic=20v1?= =?UTF-8?q?=20on=20Python=203.14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/benchmarks/test_general_performance.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/benchmarks/test_general_performance.py b/tests/benchmarks/test_general_performance.py index af26df055..ce558f82f 100644 --- a/tests/benchmarks/test_general_performance.py +++ b/tests/benchmarks/test_general_performance.py @@ -6,7 +6,6 @@ from typing import Annotated, Any import pytest from fastapi import Depends, FastAPI from fastapi.testclient import TestClient -from pydantic import BaseModel, v1 if "--codspeed" not in sys.argv: pytest.skip( @@ -49,12 +48,19 @@ def dep_b(a: Annotated[int, Depends(dep_a)]): @pytest.fixture( scope="module", params=[ - pytest.param(BaseModel, id="pydantic-v2"), - pytest.param(v1.BaseModel, id="pydantic-v1"), + "pydantic-v2", + "pydantic-v1", ], ) def basemodel_class(request: pytest.FixtureRequest) -> type[Any]: - return request.param + if request.param == "pydantic-v2": + from pydantic import BaseModel + + return BaseModel + else: + from pydantic_v1 import BaseModel + + return BaseModel @pytest.fixture(scope="module")