Bug with async callable class dependency in fastapi>=0.123.6 #14452
Answered
by
YuriiMotov
tanguy-michardiere
asked this question in
Questions
-
First Check
Commit to Help
Example Codefrom typing import Annotated
from fastapi import Depends, FastAPI
from fastapi.dependencies.models import Dependant
from uvicorn import run
class Dependency:
def __init__(self):
print("init")
async def __call__(self):
print("call")
print(Dependant(Dependency).is_coroutine_callable)
# `True` with fastapi>=0.123.6
# `False` with fastapi<0.123.6
app = FastAPI()
@app.get("/")
async def route(*, dependency: Annotated[Dependency, Depends()]):
await dependency()
run(app)
# then `curl localhost:8000`Description
Operating SystemmacOS Operating System DetailsNo response FastAPI Version0.123.7 Pydantic Version2.12.5 Python Version3.14.1 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Answered by
YuriiMotov
Dec 4, 2025
Replies: 2 comments
-
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Here is my attempt to fix this: #14458 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
tiangolo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is my attempt to fix this: #14458