Update dependency fastapi to v0.108.0 #42

Merged
profitroll merged 1 commits from renovate/fastapi-0.x into dev 2023-12-28 19:39:28 +02:00
Collaborator

This PR contains the following updates:

Package Update Change
fastapi minor ==0.105.0 -> ==0.108.0

Release Notes

tiangolo/fastapi (fastapi)

v0.108.0

Compare Source

Upgrades
  • ⬆️ Upgrade Starlette to >=0.29.0,<0.33.0, update docs and usage of templates with new Starlette arguments. PR #​10846 by @​tiangolo.

v0.107.0

Compare Source

Upgrades
Docs

v0.106.0

Compare Source

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 Tasks

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}")

@&#8203;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.


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Enabled.

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 Renovate Bot.

This PR contains the following updates: | Package | Update | Change | |---|---|---| | [fastapi](https://github.com/tiangolo/fastapi) | minor | `==0.105.0` -> `==0.108.0` | --- ### Release Notes <details> <summary>tiangolo/fastapi (fastapi)</summary> ### [`v0.108.0`](https://github.com/tiangolo/fastapi/releases/tag/0.108.0) [Compare Source](https://github.com/tiangolo/fastapi/compare/0.107.0...0.108.0) ##### Upgrades - ⬆️ Upgrade Starlette to `>=0.29.0,<0.33.0`, update docs and usage of templates with new Starlette arguments. PR [#&#8203;10846](https://github.com/tiangolo/fastapi/pull/10846) by [@&#8203;tiangolo](https://github.com/tiangolo). ### [`v0.107.0`](https://github.com/tiangolo/fastapi/releases/tag/0.107.0) [Compare Source](https://github.com/tiangolo/fastapi/compare/0.106.0...0.107.0) ##### Upgrades - ⬆️ Upgrade Starlette to 0.28.0. PR [#&#8203;9636](https://github.com/tiangolo/fastapi/pull/9636) by [@&#8203;adriangb](https://github.com/adriangb). ##### Docs - 📝 Add docs: Node.js script alternative to update OpenAPI for generated clients. PR [#&#8203;10845](https://github.com/tiangolo/fastapi/pull/10845) by [@&#8203;alejsdev](https://github.com/alejsdev). - 📝 Restructure Docs section in Contributing page. PR [#&#8203;10844](https://github.com/tiangolo/fastapi/pull/10844) by [@&#8203;alejsdev](https://github.com/alejsdev). ### [`v0.106.0`](https://github.com/tiangolo/fastapi/releases/tag/0.106.0) [Compare Source](https://github.com/tiangolo/fastapi/compare/0.105.0...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 Tasks Dependencies with `yield` now can raise `HTTPException` and other exceptions after `yield`. 🎉 Read the new docs here: [Dependencies with `yield` and `HTTPException`](https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-with-yield/#dependencies-with-yield-and-httpexception). ```Python 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}") @&#8203;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](https://fastapi.tiangolo.com/tutorial/handling-errors/#install-custom-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](https://fastapi.tiangolo.com/release-notes/#&#8203;01060). The new execution flow can be found in the docs: [Execution of dependencies with `yield`](https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-with-yield/#execution-of-dependencies-with-yield). </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **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. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4zNS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMzUuMCIsInRhcmdldEJyYW5jaCI6ImRldiJ9-->
Renovate added 1 commit 2023-12-25 20:18:08 +02:00
Renovate scheduled this pull request to auto merge when all checks succeed 2023-12-25 20:18:08 +02:00
Renovate force-pushed renovate/fastapi-0.x from 65adfaf57a to 1f7706f435 2023-12-26 21:28:23 +02:00 Compare
Renovate changed title from Update dependency fastapi to v0.106.0 to Update dependency fastapi to v0.107.0 2023-12-26 21:28:24 +02:00
Renovate force-pushed renovate/fastapi-0.x from 1f7706f435 to e6c0a53742 2023-12-26 22:33:59 +02:00 Compare
Renovate changed title from Update dependency fastapi to v0.107.0 to Update dependency fastapi to v0.108.0 2023-12-26 22:34:02 +02:00
profitroll merged commit 7adf849150 into dev 2023-12-28 19:39:28 +02:00
profitroll deleted branch renovate/fastapi-0.x 2023-12-28 19:39:28 +02:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: profitroll/PhotosAPI#42
No description provided.