fix(deps): update dependency fastapi to ^0.109.0 - autoclosed
This MR contains the following updates:
Package | Change | Age | Adoption | Passing | Confidence |
---|---|---|---|---|---|
fastapi |
^0.104.1 -> ^0.109.0
|
Release Notes
tiangolo/fastapi (fastapi)
v0.109.0
Features
Upgrades
-
⬆ ️ Upgrade Starlette to >=0.35.0,<0.36.0. MR #10938 by @tiangolo.
Docs
-
✏ ️ Fix typo indocs/en/docs/alternatives.md
. MR #10931 by @s111d. -
📝 Replaceemail
withusername
indocs_src/security/tutorial007
code examples. MR #10649 by @nilslindemann. -
📝 Add VS Code tutorial link. MR #10592 by @nilslindemann. -
📝 Add notes about Pydantic v2's new.model_dump()
. MR #10929 by @tiangolo. -
📝 Fix broken link indocs/en/docs/tutorial/sql-databases.md
. MR #10765 by @HurSungYun. -
📝 Add External Link: FastAPI application monitoring made easy. MR #10917 by @tiangolo. -
✨ Generate automatic language names for docs translations. MR #5354 by @jakul. -
✏ ️ Fix typos indocs/en/docs/alternatives.md
anddocs/en/docs/tutorial/dependencies/index.md
. MR #10906 by @s111d. -
✏ ️ Fix typos indocs/en/docs/tutorial/dependencies/dependencies-with-yield.md
. MR #10834 by @Molkree. -
📝 Add article: "Building a RESTful API with FastAPI: Secure Signup and Login Functionality Included". MR #9733 by @dxphilo. -
📝 Add warning about lifecycle events withAsyncClient
. MR #4167 by @andrew-chang-dewitt. -
✏ ️ Fix typos in/docs/reference/exceptions.md
and/en/docs/reference/status.md
. MR #10809 by @clarencepenz. -
✏ ️ Fix typo inopenapi-callbacks.md
. MR #10673 by @kayjan. -
✏ ️ Fix typo infastapi/routing.py
. MR #10520 by @sepsh. -
📝 Replace HTTP code returned in case of existing user error in docs for testing. MR #4482 by @TristanMarion. -
📝 Add blog for FastAPI & Supabase. MR #6018 by @theinfosecguy. -
📝 Update example source files for SQL databases with SQLAlchemy. MR #9508 by @s-mustafa. -
📝 Update code examples in docs for body, replace namecreate_item
withupdate_item
when appropriate. MR #5913 by @OttoAndrey. -
✏ ️ Fix typo in dependencies with yield source examples. MR #10847 by @tiangolo.
Translations
-
🌐 Add Bengali translation fordocs/bn/docs/index.md
. MR #9177 by @Fahad-Md-Kamal. -
✏ ️ Update Python version inindex.md
in several languages. MR #10711 by @tamago3keran. -
🌐 Add Russian translation fordocs/ru/docs/tutorial/request-forms-and-files.md
. MR #10347 by @AlertRED. -
🌐 Add Ukrainian translation fordocs/uk/docs/index.md
. MR #10362 by @rostik1410. -
✏ ️ Update Python version indocs/ko/docs/index.md
. MR #10680 by @Eeap. -
🌐 Add Persian translation fordocs/fa/docs/features.md
. MR #5887 by @amirilf. -
🌐 Add Chinese translation fordocs/zh/docs/advanced/additional-responses.md
. MR #10325 by @ShuibeiC. -
🌐 Fix typos in Russian translations fordocs/ru/docs/tutorial/background-tasks.md
,docs/ru/docs/tutorial/body-nested-models.md
,docs/ru/docs/tutorial/debugging.md
,docs/ru/docs/tutorial/testing.md
. MR #10311 by @AlertRED. -
🌐 Add Russian translation fordocs/ru/docs/tutorial/request-files.md
. MR #10332 by @AlertRED. -
🌐 Add Chinese translation fordocs/zh/docs/deployment/server-workers.md
. MR #10292 by @xzmeng. -
🌐 Add Chinese translation fordocs/zh/docs/deployment/cloud.md
. MR #10291 by @xzmeng. -
🌐 Add Chinese translation fordocs/zh/docs/deployment/manually.md
. MR #10279 by @xzmeng. -
🌐 Add Chinese translation fordocs/zh/docs/deployment/https.md
. MR #10277 by @xzmeng. -
🌐 Add Chinese translation fordocs/zh/docs/deployment/index.md
. MR #10275 by @xzmeng. -
🌐 Add German translation fordocs/de/docs/tutorial/first-steps.md
. MR #9530 by @fhabers21. -
🌐 Update Turkish translation fordocs/tr/docs/index.md
. MR #10444 by @hasansezertasan. -
🌐 Add Chinese translation fordocs/zh/docs/learn/index.md
. MR #10479 by @KAZAMA-DREAM. -
🌐 Add Russian translation fordocs/ru/docs/learn/index.md
. MR #10539 by @AlertRED. -
🌐 Update SQLAlchemy instruction in Chinese translationdocs/zh/docs/tutorial/sql-databases.md
. MR #9712 by @Royc30ne. -
🌐 Add Turkish translation fordocs/tr/docs/external-links.md
. MR #10549 by @hasansezertasan. -
🌐 Add Spanish translation fordocs/es/docs/learn/index.md
. MR #10885 by @pablocm83. -
🌐 Add Ukrainian translation fordocs/uk/docs/tutorial/body-fields.md
. MR #10670 by @ArtemKhymenko. -
🌐 Add Hungarian translation for/docs/hu/docs/index.md
. MR #10812 by @takacs. -
🌐 Add Turkish translation fordocs/tr/docs/newsletter.md
. MR #10550 by @hasansezertasan. -
🌐 Add Spanish translation fordocs/es/docs/help/index.md
. MR #10907 by @pablocm83. -
🌐 Add Spanish translation fordocs/es/docs/about/index.md
. MR #10908 by @pablocm83. -
🌐 Add Spanish translation fordocs/es/docs/resources/index.md
. MR #10909 by @pablocm83.
Internal
-
👥 Update FastAPI People. MR #10871 by @tiangolo. -
👷 Upgrade custom GitHub Action comment-docs-preview-in-pr. MR #10916 by @tiangolo. -
⬆ ️ Upgrade GitHub Action latest-changes. MR #10915 by @tiangolo. -
👷 Upgrade GitHub Action label-approved. MR #10913 by @tiangolo. -
⬆ ️ Upgrade GitHub Action label-approved. MR #10905 by @tiangolo.
v0.108.0
Upgrades
-
⬆ ️ Upgrade Starlette to>=0.29.0,<0.33.0
, update docs and usage of templates with new Starlette arguments. MR #10846 by @tiangolo.
v0.107.0
Upgrades
-
⬆ ️ Upgrade Starlette to 0.28.0. MR #9636 by @adriangb.
Docs
-
📝 Add docs: Node.js script alternative to update OpenAPI for generated clients. MR #10845 by @alejsdev. -
📝 Restructure Docs section in Contributing page. MR #10844 by @alejsdev.
v0.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.
yield
, HTTPException
and Background Tasks
Dependencies with Dependencies with yield
now can raise HTTPException
and other exceptions after yield
.
Read the new docs here: Dependencies with yield
and HTTPException
.
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 with yield
was executed after the response was sent, so Exception Handlers would have already run.
This was designed this way mainly to allow using the same objects "yielded" by dependencies inside of background tasks, because the exit code would be executed after the background tasks were finished.
Nevertheless, as this would mean waiting for the response to travel through the network while unnecessarily holding a resource in a dependency with yield (for example a database connection), this was changed in FastAPI 0.106.0.
Additionally, a background task is normally an independent set of logic that should be handled separately, with its own resources (e.g. its own database connection).
If you used to rely on this behavior, now you should create the resources for background tasks inside the background task itself, and use internally only data that doesn't depend on the resources of dependencies with yield
.
For example, instead of using the same database session, you would create a new database session inside of the background task, and you would obtain the objects from the database using this new session. And then instead of passing the object from the database as a parameter to the background task function, you would pass the ID of that object and then obtain the object again inside the background task function.
The sequence of execution before FastAPI 0.106.0 was like the diagram in the Release Notes for FastAPI 0.106.0.
The new execution flow can be found in the docs: Execution of dependencies with yield
.
v0.105.0
Features
-
✨ Add support for multiple Annotated annotations, e.g.Annotated[str, Field(), Query()]
. MR #10773 by @tiangolo.
Refactors
-
🔥 Remove unused NoneType. MR #10774 by @tiangolo.
Docs
-
📝 Tweak default suggested configs for generating clients. MR #10736 by @tiangolo.
Internal
-
🔧 Update sponsors, add Scalar. MR #10728 by @tiangolo. -
🔧 Update sponsors, add PropelAuth. MR #10760 by @tiangolo. -
👷 Update build docs, verify README on CI. MR #10750 by @tiangolo. -
🔧 Update sponsors, remove Fern. MR #10729 by @tiangolo. -
🔧 Update sponsors, add Codacy. MR #10677 by @tiangolo. -
🔧 Update sponsors, add Reflex. MR #10676 by @tiangolo. -
📝 Update release notes, move and check latest-changes. MR #10588 by @tiangolo. -
👷 Upgrade latest-changes GitHub Action. MR #10587 by @tiangolo.
Configuration
-
If you want to rebase/retry this MR, check this box
This MR has been generated by Renovate Bot.