Commit Graph

9 Commits

Author SHA1 Message Date
lif b89a15d575 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>
2025-12-25 23:46:11 +08:00
pre-commit-ci-lite[bot] b8ab033080
🎨 Auto format 2025-12-25 15:41:17 +00:00
lif f7e2c39524 test: add comprehensive tests for _try_resolve_annotated_string
Add unit tests for:
- Invalid annotation formats (missing prefix/suffix)
- Non-Depends metadata (Query, etc.)
- Eval failures for undefined functions
- Nested brackets in type annotations
- ForwardRef type resolution failures
- Exception handling with partial resolution fallback
- Resolved Annotated types
- get_typed_signature edge cases

These tests improve coverage for the forward reference handling code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 23:40:35 +08:00
lif 70bd7a592e Exclude manual test runner from coverage 2025-12-21 17:48:45 +08:00
lif 831fd18892 fix: resolve ruff lint errors (Dict -> dict, remove outdated version block) 2025-12-18 22:13:08 +08:00
pre-commit-ci-lite[bot] dc6c5b8917
🎨 Auto format 2025-12-18 13:22:49 +00:00
lif c171f468d8 Fix CI failures: Python 3.8 compatibility and Pydantic v1 tests
- Fix Python 3.8 compatibility by importing Annotated from typing_extensions
  when running on Python < 3.9
- Simplify get_typed_signature to not use get_type_hints which was causing
  issues with Pydantic v1 parameter detection (Header, Cookie, Query, etc.)
- Instead, expand globalns with module namespace to help resolve forward
  references while keeping the original annotation resolution logic intact

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 21:21:13 +08:00
pre-commit-ci-lite[bot] a975a1704e
🎨 Auto format 2025-12-17 16:28:11 +00:00
lif 9e7ca4d454 Fix Annotated with ForwardRef when using future annotations
When using `from __future__ import annotations` with `Annotated[SomeClass, Depends()]`
where SomeClass is defined after the function, FastAPI was unable to properly
resolve the forward reference and treated the parameter as a query parameter
instead of a dependency.

This fix adds special handling to partially resolve Annotated string annotations,
extracting metadata (like Depends) even when the inner type cannot be fully resolved.

Fixes #13056
2025-12-18 00:27:08 +08:00