From 279e17689bf4754674bc429b7995471615f9dcd5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 3 Nov 2023 18:21:59 +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/dependencies/utils.py | 2 +- tests/test_dependency_schema_query.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py index ffa798b1c..f5bc230ce 100644 --- a/fastapi/dependencies/utils.py +++ b/fastapi/dependencies/utils.py @@ -220,7 +220,7 @@ def get_typed_signature(call: Callable[..., Any]) -> inspect.Signature: query_extra_info[param] = dict(fields[param].__repr_args__()) else: query_extra_info[param] = dict(fields[param].field_info.__repr_args__()) - + if "alias" in query_extra_info[param]: if PYDANTIC_V2: query_extra_info[query_extra_info[param]["alias"]] = dict( diff --git a/tests/test_dependency_schema_query.py b/tests/test_dependency_schema_query.py index d1d809c90..79f172eac 100644 --- a/tests/test_dependency_schema_query.py +++ b/tests/test_dependency_schema_query.py @@ -5,7 +5,6 @@ from fastapi.testclient import TestClient from pydantic import BaseModel from pydantic.version import VERSION as PYDANTIC_VERSION - PYDANTIC_V2 = PYDANTIC_VERSION.startswith("2.") app = FastAPI() @@ -358,9 +357,13 @@ def test_openapi_schema_with_query_dependency(): response = client.get("/openapi.json") assert response.status_code == 200, response.text if PYDANTIC_V2: - assert response.json() == openapi_schema_with_not_omitted_description_pydantic_v2 + assert ( + response.json() == openapi_schema_with_not_omitted_description_pydantic_v2 + ) else: - assert response.json() == openapi_schema_with_not_omitted_description_pydantic_v1 + assert ( + response.json() == openapi_schema_with_not_omitted_description_pydantic_v1 + ) def test_response():