Browse Source
When from __future__ import annotations is active, an annotation like Annotated[Potato, Depends(get_potato)] stays as a ForwardRef because the lenient evaluator cannot resolve *Potato* (defined later in the file). This meant the Depends() marker was never discovered and the parameter was incorrectly treated as a body field instead of a dependency. Use eval with a safe-globals dict that turns undefined names into ForwardRef objects, allowing the Annotated wrapper to be unpacked so that FastAPI-specific markers (Depends / Field / Body) are found. Fixes #13056pull/15411/head
1 changed files with 34 additions and 1 deletions
Loading…
Reference in new issue