Privileged issue
Issue Content
FastAPI 0.95.0 introduced Annotated as a way to create dependencies (https://fastapi.tiangolo.com/release-notes/#0950).
Before 0.95.0, it was possible to use Response as a type hint for dependencies. After that, it was not possible anymore.
Example that worked before:
from typing import Annotated
from fastapi import FastAPI, Response, Depends
app = FastAPI()
def set_no_cache_headers(response: Response) -> Response:
response.headers["Potato"] = "potato"
return response
@app.get("/")
def testing_response(response: Response = Depends(set_no_cache_headers)):
return {}
As a workaround today, if you remove the Response type hint, it works as expected:
@app.get("/")
def testing_response(response = Depends(set_no_cache_headers)):
return {}
The Annotated way also doesn't work:
@app.get("/")
def testing_response(response: Annotated[Response, Depends(set_no_cache_headers)]):
return {}
Privileged issue
Issue Content
FastAPI
0.95.0introducedAnnotatedas a way to create dependencies (https://fastapi.tiangolo.com/release-notes/#0950).Before
0.95.0, it was possible to useResponseas a type hint for dependencies. After that, it was not possible anymore.Example that worked before:
As a workaround today, if you remove the
Responsetype hint, it works as expected:The
Annotatedway also doesn't work: