mirror of https://github.com/tiangolo/fastapi.git
fix: use params.Depends instead of Depends for isinstance check
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 <noreply@anthropic.com>
This commit is contained in:
parent
b8ab033080
commit
b89a15d575
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue