From d2ad276dc14fffd16321d4b0161383b607c83ad0 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, 8 Feb 2026 10:10:24 +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 --- tests/test_annotated_forwardref.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/test_annotated_forwardref.py b/tests/test_annotated_forwardref.py index 96f4f5283d..fc44139202 100644 --- a/tests/test_annotated_forwardref.py +++ b/tests/test_annotated_forwardref.py @@ -6,7 +6,7 @@ Tests for issue #13056: Annotated types with ForwardRef cause errors. from typing import Annotated, Optional import pytest -from fastapi import FastAPI, Query, Header, Path, Body +from fastapi import Body, FastAPI, Header, Path, Query from fastapi.testclient import TestClient from pydantic import BaseModel @@ -106,9 +106,13 @@ def test_annotated_forwardref_body(): return {"item": item} client = TestClient(app) - response = client.post("/items", json={"title": "Test Item", "description": "A test item"}) + response = client.post( + "/items", json={"title": "Test Item", "description": "A test item"} + ) assert response.status_code == 200 - assert response.json() == {"item": {"title": "Test Item", "description": "A test item"}} + assert response.json() == { + "item": {"title": "Test Item", "description": "A test item"} + } def test_annotated_forwardref_multiple_annotations(): @@ -117,7 +121,7 @@ def test_annotated_forwardref_multiple_annotations(): @app.get("/multi") async def get_multi( - param: Annotated["UserModel", "some metadata", Query(), "more metadata"] + param: Annotated["UserModel", "some metadata", Query(), "more metadata"], ): return {"param": param} @@ -170,9 +174,7 @@ def test_annotated_forwardref_with_dependencies(): """Test Annotated with ForwardRef in dependency chain.""" app = FastAPI() - def get_current_user( - user: Annotated["UserModel", Query()] - ) -> "UserModel": + def get_current_user(user: Annotated["UserModel", Query()]) -> "UserModel": return user @app.get("/protected") @@ -190,15 +192,16 @@ def test_annotated_forwardref_complex_types(): app = FastAPI() @app.get("/search") - async def search( - items: Annotated[list["Item"], Query()] = None - ): + async def search(items: Annotated[list["Item"], Query()] = None): return {"items": items or []} client = TestClient(app) # This tests that complex types with ForwardRef don't break the system response = client.get("/search") - assert response.status_code in [200, 422] # May be 422 if the type check is too strict + assert response.status_code in [ + 200, + 422, + ] # May be 422 if the type check is too strict if __name__ == "__main__":