FastAPI: How to use a callable class as a dependency with sub-dependencies in Python 3.14+? #14394
Replies: 2 comments
This comment was marked as disruptive content.
This comment was marked as disruptive content.
-
|
Just drop |
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
When I try to run this with Python 3.14+ and FastAPI 0.121.x, the endpoint /auth fails to start.
The error mentions unresolved ForwardRef objects, and the dependency parameters are treated as query parameters.
I expected FastAPI to correctly inject the value dependency into the callable class, but it does not work.
Operating System
macOS
Operating System Details
No response
FastAPI Version
FastAPI: 0.121.2
Pydantic Version
Pydantic: 2.1.4
Python Version
Python: 3.14.0
Additional Context
I read about a similar issue caused by from future import annotations affecting callable instances. I’d like guidance on the correct pattern to make callable classes work with sub-dependencies in Python 3.14+ without breaking OpenAPI generation.
Beta Was this translation helpful? Give feedback.
All reactions