tiangolo/fastapi
### [`v0.93.0`](https://togithub.com/tiangolo/fastapi/releases/tag/0.93.0)
[Compare Source](https://togithub.com/tiangolo/fastapi/compare/0.92.0...0.93.0)
##### Features
- ✨ Add support for `lifespan` async context managers (superseding `startup` and `shutdown` events). Initial PR [#2944](https://togithub.com/tiangolo/fastapi/pull/2944) by [@uSpike](https://togithub.com/uSpike).
Now, instead of using independent `startup` and `shutdown` events, you can define that logic in a single function with `yield` decorated with `@asynccontextmanager` (an async context manager).
For example:
```Python
from contextlib import asynccontextmanager
from fastapi import FastAPI
def fake_answer_to_everything_ml_model(x: float):
return x * 42
ml_models = {}
@asynccontextmanager
async def lifespan(app: FastAPI):
### Load the ML model
ml_models["answer_to_everything"] = fake_answer_to_everything_ml_model
yield
### Clean up the ML models and release the resources
ml_models.clear()
app = FastAPI(lifespan=lifespan)
@app.get("/predict")
async def predict(x: float):
result = ml_models["answer_to_everything"](x)
return {"result": result}
```
**Note**: This is the recommended way going forward, instead of using `startup` and `shutdown` events.
Read more about it in the new docs: [Advanced User Guide: Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
##### Docs
- ✏ Fix formatting in `docs/en/docs/tutorial/metadata.md` for `ReDoc`. PR [#6005](https://togithub.com/tiangolo/fastapi/pull/6005) by [@eykamp](https://togithub.com/eykamp).
##### Translations
- 🌐 Tamil translations - initial setup. PR [#5564](https://togithub.com/tiangolo/fastapi/pull/5564) by [@gusty1g](https://togithub.com/gusty1g).
- 🌐 Add French translation for `docs/fr/docs/advanced/path-operation-advanced-configuration.md`. PR [#9221](https://togithub.com/tiangolo/fastapi/pull/9221) by [@axel584](https://togithub.com/axel584).
- 🌐 Add French translation for `docs/tutorial/debugging.md`. PR [#9175](https://togithub.com/tiangolo/fastapi/pull/9175) by [@frabc](https://togithub.com/frabc).
- 🌐 Initiate Armenian translation setup. PR [#5844](https://togithub.com/tiangolo/fastapi/pull/5844) by [@har8](https://togithub.com/har8).
- 🌐 Add French translation for `deployment/manually.md`. PR [#3693](https://togithub.com/tiangolo/fastapi/pull/3693) by [@rjNemo](https://togithub.com/rjNemo).
##### Internal
- 👷 Update translation bot messages. PR [#9206](https://togithub.com/tiangolo/fastapi/pull/9206) by [@tiangolo](https://togithub.com/tiangolo).
- 👷 Update translations bot to use Discussions, and notify when a PR is done. PR [#9183](https://togithub.com/tiangolo/fastapi/pull/9183) by [@tiangolo](https://togithub.com/tiangolo).
- 🔧 Update sponsors-badges. PR [#9182](https://togithub.com/tiangolo/fastapi/pull/9182) by [@tiangolo](https://togithub.com/tiangolo).
- 👥 Update FastAPI People. PR [#9181](https://togithub.com/tiangolo/fastapi/pull/9181) by [@github-actions\[bot\]](https://togithub.com/apps/github-actions).
- 🔊 Log GraphQL errors in FastAPI People, because it returns 200, with a payload with an error. PR [#9171](https://togithub.com/tiangolo/fastapi/pull/9171) by [@tiangolo](https://togithub.com/tiangolo).
- 💚 Fix/workaround GitHub Actions in Docker with git for FastAPI People. PR [#9169](https://togithub.com/tiangolo/fastapi/pull/9169) by [@tiangolo](https://togithub.com/tiangolo).
- ♻️ Refactor FastAPI Experts to use only discussions now that questions are migrated. PR [#9165](https://togithub.com/tiangolo/fastapi/pull/9165) by [@tiangolo](https://togithub.com/tiangolo).
- ⬆️ Upgrade analytics. PR [#6025](https://togithub.com/tiangolo/fastapi/pull/6025) by [@tiangolo](https://togithub.com/tiangolo).
- ⬆️ Upgrade and re-enable installing Typer-CLI. PR [#6008](https://togithub.com/tiangolo/fastapi/pull/6008) by [@tiangolo](https://togithub.com/tiangolo).
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
[ ] If you want to rebase/retry this PR, check this box
This PR has been generated by Mend Renovate. View repository job log here.
This PR contains the following updates:
<=0.92.0
-><=0.93.0
Release Notes
tiangolo/fastapi
### [`v0.93.0`](https://togithub.com/tiangolo/fastapi/releases/tag/0.93.0) [Compare Source](https://togithub.com/tiangolo/fastapi/compare/0.92.0...0.93.0) ##### Features - ✨ Add support for `lifespan` async context managers (superseding `startup` and `shutdown` events). Initial PR [#2944](https://togithub.com/tiangolo/fastapi/pull/2944) by [@uSpike](https://togithub.com/uSpike). Now, instead of using independent `startup` and `shutdown` events, you can define that logic in a single function with `yield` decorated with `@asynccontextmanager` (an async context manager). For example: ```Python from contextlib import asynccontextmanager from fastapi import FastAPI def fake_answer_to_everything_ml_model(x: float): return x * 42 ml_models = {} @asynccontextmanager async def lifespan(app: FastAPI): ### Load the ML model ml_models["answer_to_everything"] = fake_answer_to_everything_ml_model yield ### Clean up the ML models and release the resources ml_models.clear() app = FastAPI(lifespan=lifespan) @app.get("/predict") async def predict(x: float): result = ml_models["answer_to_everything"](x) return {"result": result} ``` **Note**: This is the recommended way going forward, instead of using `startup` and `shutdown` events. Read more about it in the new docs: [Advanced User Guide: Lifespan Events](https://fastapi.tiangolo.com/advanced/events/). ##### Docs - ✏ Fix formatting in `docs/en/docs/tutorial/metadata.md` for `ReDoc`. PR [#6005](https://togithub.com/tiangolo/fastapi/pull/6005) by [@eykamp](https://togithub.com/eykamp). ##### Translations - 🌐 Tamil translations - initial setup. PR [#5564](https://togithub.com/tiangolo/fastapi/pull/5564) by [@gusty1g](https://togithub.com/gusty1g). - 🌐 Add French translation for `docs/fr/docs/advanced/path-operation-advanced-configuration.md`. PR [#9221](https://togithub.com/tiangolo/fastapi/pull/9221) by [@axel584](https://togithub.com/axel584). - 🌐 Add French translation for `docs/tutorial/debugging.md`. PR [#9175](https://togithub.com/tiangolo/fastapi/pull/9175) by [@frabc](https://togithub.com/frabc). - 🌐 Initiate Armenian translation setup. PR [#5844](https://togithub.com/tiangolo/fastapi/pull/5844) by [@har8](https://togithub.com/har8). - 🌐 Add French translation for `deployment/manually.md`. PR [#3693](https://togithub.com/tiangolo/fastapi/pull/3693) by [@rjNemo](https://togithub.com/rjNemo). ##### Internal - 👷 Update translation bot messages. PR [#9206](https://togithub.com/tiangolo/fastapi/pull/9206) by [@tiangolo](https://togithub.com/tiangolo). - 👷 Update translations bot to use Discussions, and notify when a PR is done. PR [#9183](https://togithub.com/tiangolo/fastapi/pull/9183) by [@tiangolo](https://togithub.com/tiangolo). - 🔧 Update sponsors-badges. PR [#9182](https://togithub.com/tiangolo/fastapi/pull/9182) by [@tiangolo](https://togithub.com/tiangolo). - 👥 Update FastAPI People. PR [#9181](https://togithub.com/tiangolo/fastapi/pull/9181) by [@github-actions\[bot\]](https://togithub.com/apps/github-actions). - 🔊 Log GraphQL errors in FastAPI People, because it returns 200, with a payload with an error. PR [#9171](https://togithub.com/tiangolo/fastapi/pull/9171) by [@tiangolo](https://togithub.com/tiangolo). - 💚 Fix/workaround GitHub Actions in Docker with git for FastAPI People. PR [#9169](https://togithub.com/tiangolo/fastapi/pull/9169) by [@tiangolo](https://togithub.com/tiangolo). - ♻️ Refactor FastAPI Experts to use only discussions now that questions are migrated. PR [#9165](https://togithub.com/tiangolo/fastapi/pull/9165) by [@tiangolo](https://togithub.com/tiangolo). - ⬆️ Upgrade analytics. PR [#6025](https://togithub.com/tiangolo/fastapi/pull/6025) by [@tiangolo](https://togithub.com/tiangolo). - ⬆️ Upgrade and re-enable installing Typer-CLI. PR [#6008](https://togithub.com/tiangolo/fastapi/pull/6008) by [@tiangolo](https://togithub.com/tiangolo).Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.