From b89a15d57534d71baa19e1ecc29819b1cfc81051 Mon Sep 17 00:00:00 2001 From: lif <1835304752@qq.com> Date: Thu, 25 Dec 2025 23:46:03 +0800 Subject: [PATCH] fix: use params.Depends instead of Depends for isinstance check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Depends function returns a params.Depends instance, so we need to check isinstance against params.Depends, not the Depends function itself. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- tests/test_annotated_forward_ref.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_annotated_forward_ref.py b/tests/test_annotated_forward_ref.py index 45f253a12a..4d462f53a9 100644 --- a/tests/test_annotated_forward_ref.py +++ b/tests/test_annotated_forward_ref.py @@ -109,7 +109,7 @@ def test_try_resolve_annotated_string_with_nested_brackets(): def test_try_resolve_annotated_string_forwardref_type_fails(): """Test when type part can't be resolved as ForwardRef.""" - from fastapi import Depends + from fastapi import Depends, params from fastapi.dependencies.utils import _try_resolve_annotated_string def get_item(): @@ -127,7 +127,7 @@ def test_try_resolve_annotated_string_forwardref_type_fails(): assert get_origin(result) is Annotated args = get_args(result) assert args[0] is Any - assert isinstance(args[1], Depends) + assert isinstance(args[1], params.Depends) def test_get_typed_annotation_with_resolved_annotated(): @@ -156,7 +156,7 @@ def test_get_typed_annotation_with_resolved_annotated(): def test_get_typed_annotation_exception_with_partial_resolution(): """Test get_typed_annotation exception handling with partial resolution fallback.""" - from fastapi import Depends + from fastapi import Depends, params from fastapi.dependencies.utils import get_typed_annotation def get_value() -> str: @@ -173,7 +173,7 @@ def test_get_typed_annotation_exception_with_partial_resolution(): if get_origin(result) is Annotated: args = get_args(result) assert args[0] is Any - assert isinstance(args[1], Depends) + assert isinstance(args[1], params.Depends) def test_get_typed_signature_no_module(): @@ -214,7 +214,7 @@ def test_try_resolve_annotated_string_with_resolved_type(): """Test _try_resolve_annotated_string when type can be resolved.""" from typing import Annotated, get_args, get_origin - from fastapi import Depends + from fastapi import Depends, params from fastapi.dependencies.utils import _try_resolve_annotated_string def get_value() -> str: @@ -229,7 +229,7 @@ def test_try_resolve_annotated_string_with_resolved_type(): assert get_origin(result) is Annotated args = get_args(result) assert args[0] is str - assert isinstance(args[1], Depends) + assert isinstance(args[1], params.Depends) if __name__ == "__main__": # pragma: no cover