From b8ab033080af2c04508b595ca51638b488cebc3c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Thu, 25 Dec 2025 15:41:17 +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_forward_ref.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/tests/test_annotated_forward_ref.py b/tests/test_annotated_forward_ref.py index 0748a4c43a..45f253a12a 100644 --- a/tests/test_annotated_forward_ref.py +++ b/tests/test_annotated_forward_ref.py @@ -86,9 +86,7 @@ def test_try_resolve_annotated_string_eval_failure(): from fastapi.dependencies.utils import _try_resolve_annotated_string # Invalid metadata expression that can't be evaluated - result = _try_resolve_annotated_string( - "Annotated[str, UndefinedFunction()]", {} - ) + result = _try_resolve_annotated_string("Annotated[str, UndefinedFunction()]", {}) assert result is None @@ -124,9 +122,7 @@ def test_try_resolve_annotated_string_forwardref_type_fails(): ) # Should return Annotated[Any, Depends(...)] since type can't be resolved if result is not None: - from typing import Any, get_args, get_origin - - from typing_extensions import Annotated + from typing import Annotated, Any, get_args, get_origin assert get_origin(result) is Annotated args = get_args(result) @@ -145,7 +141,12 @@ def test_get_typed_annotation_with_resolved_annotated(): return "value" # Create a resolvable Annotated string - globalns = {"Annotated": Annotated, "str": str, "Depends": Depends, "get_value": get_value} + globalns = { + "Annotated": Annotated, + "str": str, + "Depends": Depends, + "get_value": get_value, + } result = get_typed_annotation("Annotated[str, Depends(get_value)]", globalns) # Should resolve successfully from typing import get_origin @@ -167,9 +168,7 @@ def test_get_typed_annotation_exception_with_partial_resolution(): "Annotated[UndefinedType, Depends(get_value)]", globalns ) # Should fall back to partial resolution and return Annotated[Any, Depends(...)] - from typing import Any, get_args, get_origin - - from typing_extensions import Annotated + from typing import Annotated, Any, get_args, get_origin if get_origin(result) is Annotated: args = get_args(result) @@ -193,7 +192,6 @@ def test_get_typed_signature_no_module(): def test_get_typed_annotation_with_forwardref_result(): """Test get_typed_annotation when evaluate_forwardref returns a ForwardRef.""" - from typing import ForwardRef from fastapi import Depends from fastapi.dependencies.utils import get_typed_annotation @@ -205,16 +203,16 @@ def test_get_typed_annotation_with_forwardref_result(): # This happens when the type can't be resolved globalns = {"Depends": Depends, "get_value": get_value} # UndefinedClass will create a ForwardRef that can't be resolved - result = get_typed_annotation("Annotated[UndefinedClass, Depends(get_value)]", globalns) + result = get_typed_annotation( + "Annotated[UndefinedClass, Depends(get_value)]", globalns + ) # The result should be valid (either ForwardRef or Annotated with Any) assert result is not None def test_try_resolve_annotated_string_with_resolved_type(): """Test _try_resolve_annotated_string when type can be resolved.""" - from typing import get_args, get_origin - - from typing_extensions import Annotated + from typing import Annotated, get_args, get_origin from fastapi import Depends from fastapi.dependencies.utils import _try_resolve_annotated_string