Bump fastapi from 0.105.0 to 0.106.0
Bumps fastapi from 0.105.0 to 0.106.0.
Release notes
Sourced from fastapi's releases.
0.106.0
Breaking Changes
Using resources from dependencies with
yield
in background tasks is no longer supported.This change is what supports the new features, read below.
🤓 Dependencies with
yield
,HTTPException
and Background TasksDependencies with
yield
now can raiseHTTPException
and other exceptions afteryield
.🎉 Read the new docs here: Dependencies with
yield
andHTTPException
.from fastapi import Depends, FastAPI, HTTPException from typing_extensions import Annotated app = FastAPI() data = { "plumbus": {"description": "Freshly pickled plumbus", "owner": "Morty"}, "portal-gun": {"description": "Gun to create portals", "owner": "Rick"}, } class OwnerError(Exception): pass def get_username(): try: yield "Rick" except OwnerError as e: raise HTTPException(status_code=400, detail=f"Onwer error: {e}") @app.get("/items/{item_id}") def get_item(item_id: str, username: Annotated[str, Depends(get_username)]): if item_id not in data: raise HTTPException(status_code=404, detail="Item not found") item = data[item_id] if item["owner"] != username: raise OwnerError(username) return item
Before FastAPI 0.106.0, raising exceptions after
yield
was not possible, the exit code in dependencies withyield
was executed after the response was sent, so Exception Handlers would have already run.
... (truncated)
Commits
-
5826c4f
📝 Tweak release notes -
91510db
🔖 Release version 0.106.0 -
bcd5a42
📝 Update release notes -
678bed2
📝 Update release notes -
a4aa79e
✨ Add support for raising exceptions (includingHTTPException
) in dependenc... -
e7756ae
📝 Update release notes -
dc2fdd5
👥 Update FastAPI People (#10567) - See full diff in compare view