FastAPI dependency injection fails with callable class when using from __future__ import annotations #14390
Replies: 2 comments
This comment was marked as disruptive content.
This comment was marked as disruptive content.
-
Linked Discussion: #14377 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
pydantic.errors.PydanticUserError: 'TypeAdapter[typing.Annotated[ForwardRef('Request'), Query(PydanticUndefined)]]' is not fully defined
Operating System
Windows
Operating System Details
async def auth_func(request: Request, dep: Annotated[str, Depends(get_value)]):
return {"dep": dep}
FastAPI Version
FastAPI Version: 0.118.0
Pydantic Version
Pydantic Version: 2.11.10
Python Version
Python Version: 3.13.3
Additional Context
I noticed get_typed_signature() in FastAPI uses getattr(call, "globals", {}), which returns {} for callable instances.
Is there a recommended way to make callable class dependencies work with PEP 563 annotations?
Beta Was this translation helpful? Give feedback.
All reactions