Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

fix(deps): update beta #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

fix(deps): update beta #10

wants to merge 1 commit into from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Nov 4, 2022

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
fastapi 0.86.0 -> 0.106.0 age adoption passing confidence
python-dotenv 0.21.0 -> 0.21.1 age adoption passing confidence

Release Notes

tiangolo/fastapi (fastapi)

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

@​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

Compare Source

Features
  • ✨ Add support for multiple Annotated annotations, e.g. Annotated[str, Field(), Query()]. PR #​10773 by @​tiangolo.
Refactors
Docs
Internal

v0.104.1

Compare Source

Fixes
  • 📌 Pin Swagger UI version to 5.9.0 temporarily to handle a bug crashing it in 5.9.1. PR #​10529 by @​alejandraklachquin.
    • This is not really a bug in FastAPI but in Swagger UI, nevertheless pinning the version will work while a solution is found on the Swagger UI side.
Docs
Internal

v0.104.0

Compare Source

Features

Upgrades

Internal

v0.103.2

Compare Source

Refactors
  • ⬆️ Upgrade compatibility with Pydantic v2.4, new renamed functions and JSON Schema input/output models with default values. PR #​10344 by @​tiangolo.
Translations
  • 🌐 Add Ukrainian translation for docs/uk/docs/tutorial/extra-data-types.md. PR #​10132 by @​ArtemKhymenko.
  • 🌐 Fix typos in French translations for docs/fr/docs/advanced/path-operation-advanced-configuration.md, docs/fr/docs/alternatives.md, docs/fr/docs/async.md, docs/fr/docs/features.md, docs/fr/docs/help-fastapi.md, docs/fr/docs/index.md, docs/fr/docs/python-types.md, docs/fr/docs/tutorial/body.md, docs/fr/docs/tutorial/first-steps.md, docs/fr/docs/tutorial/query-params.md. PR #​10154 by @​s-rigaud.
  • 🌐 Add Chinese translation for docs/zh/docs/async.md. PR #​5591 by @​mkdir700.
  • 🌐 Update Chinese translation for docs/tutorial/security/simple-oauth2.md. PR #​3844 by @​jaystone776.
  • 🌐 Add Korean translation for docs/ko/docs/deployment/cloud.md. PR #​10191 by @​Sion99.
  • 🌐 Add Japanese translation for docs/ja/docs/deployment/https.md. PR #​10298 by @​tamtam-fitness.
  • 🌐 Fix typo in Russian translation for docs/ru/docs/tutorial/body-fields.md. PR #​10224 by @​AlertRED.
  • 🌐 Add Polish translation for docs/pl/docs/help-fastapi.md. PR #​10121 by @​romabozhanovgithub.
  • 🌐 Add Russian translation for docs/ru/docs/tutorial/header-params.md. PR #​10226 by @​AlertRED.
  • 🌐 Add Chinese translation for docs/zh/docs/deployment/versions.md. PR #​10276 by @​xzmeng.
Internal

v0.103.1

Compare Source

Fixes
  • 📌 Pin AnyIO to < 4.0.0 to handle an incompatibility while upgrading to Starlette 0.31.1. PR #​10194 by @​tiangolo.
Docs
Translations
Refactors
Internal

v0.103.0

Compare Source

Features
Docs
  • 📝 Add note to docs about Separate Input and Output Schemas with FastAPI version. PR #​10150 by @​tiangolo.

v0.102.0

Compare Source

Features
Refactors
Docs
Internal

v0.101.1

Compare Source

Fixes
  • ✨ Add ResponseValidationError printable details, to show up in server error logs. PR #​10078 by @​tiangolo.
Refactors
Docs
Translations
Internal

v0.101.0

Compare Source

Features
  • ✨ Enable Pydantic's serialization mode for responses, add support for Pydantic's computed_field, better OpenAPI for response models, proper required attributes, better generated clients. PR #​10011 by @​tiangolo.
Refactors
Upgrades
Translations
Internal

v0.100.1

Compare Source

Fixes
  • 🐛 Replace MultHostUrl to AnyUrl for compatibility with older versions of Pydantic v1. PR #​9852 by @​Kludex.
Docs
  • 📝 Update links for self-hosted Swagger UI, point to v5, for OpenAPI 31.0. PR #​9834 by @​tiangolo.
Translations
Internal

v0.100.0

Compare Source

✨ Support for Pydantic v2

Pydantic version 2 has the core re-written in Rust and includes a lot of improvements and features, for example:

  • Improved correctness in corner cases.
  • Safer types.
  • Better performance and less energy consumption.
  • Better extensibility.
  • etc.

...all this while keeping the same Python API. In most of the cases, for simple models, you can simply upgrade the Pydantic version and get all the benefits. 🚀

In some cases, for pure data validation and processing, you can get performance improvements of 20x or more. This means 2,000% or more. 🤯

When you use FastAPI, there's a lot more going on, processing the request and response, handling dependencies, executing your own code, and particularly, waiting for the network. But you will probably still get some nice performance improvements just from the upgrade.

The focus of this release is compatibility with Pydantic v1 and v2, to make sure your current apps keep working. Later there will be more focus on refactors, correctness, code improvements, and then performance improvements. Some third-party early beta testers that ran benchmarks on the beta releases of FastAPI reported improvements of 2x - 3x. Which is not bad for just doing pip install --upgrade fastapi pydantic. This was not an official benchmark and I didn't check it myself, but it's a good sign.

Migration

Check out the Pydantic migration guide.

For the things that need changes in your Pydantic models, the Pydantic team built bump-pydantic.

A command line tool that will process your code and update most of the things automatically for you. Make sure you have your code in git first, and review each of the changes to make sure everything is correct before committing the changes.

Pydantic v1

This version of FastAPI still supports Pydantic v1. And although Pydantic v1 will be deprecated at some point, ti will still be supported for a while.

This means that you can install the new Pydantic v2, and if something fails, you can install Pydantic v1 while you fix any problems you might have, but having the latest FastAPI.

There are tests for both Pydantic v1 and v2, and test coverage is kept at 100%.

Changes
  • There are new parameter fields supported by Pydantic Field() for:

    • Path()
    • Query()
    • Header()
    • Cookie()
    • Body()
    • Form()
    • File()
  • The new parameter fields are:

    • default_factory
    • alias_priority
    • validation_alias
    • serialization_alias
    • discriminator
    • strict
    • multiple_of
    • allow_inf_nan
    • max_digits
    • decimal_places
    • json_schema_extra

...you can read about them in the Pydantic docs.

  • The parameter regex has been deprecated and replaced by pattern.

  • New Pydantic models use an improved and simplified attribute model_config that takes a simple dict instead of an internal class Config for their configuration.

  • The attribute schema_extra for the internal class Config has been replaced by the key json_schema_extra in the new model_config dict.

  • When you install "fastapi[all]" it now also includes:

  • Now Pydantic Settings is an additional optional package (included in "fastapi[all]"). To use settings you should now import from pydantic_settings import BaseSettings instead of importing from pydantic directly.

  • PR #​9816 by @​tiangolo, included all the work done (in multiple PRs) on the beta branch (main-pv2).

v0.99.1

Compare Source

Fixes
  • 🐛 Fix JSON Schema accepting bools as valid JSON Schemas, e.g. additionalProperties: false. PR #​9781 by @​tiangolo.
Docs

v0.99.0

Compare Source

Note: this is the last release before supporting Pydantic v2. You can try out the beta with support for Pydantic v2 now, a new beta supporting Pydantic v2 with these same changes from this release will be available in the next hours/days. And the final version (0.100.0) with support for Pydantic v2 will be released in the next days (next week).

Now, back to this release (this one doesn't include the beta support for Pydantic v2).

This release has ✨ OpenAPI 3.1.0 ✨ 🎉

Features
  • ✨ Add support for OpenAPI 3.1.0. PR #​9770 by @​tiangolo.

    • New support for documenting webhooks, read the new docs here: Advanced User Guide: OpenAPI Webhooks.
    • Upgrade OpenAPI 3.1.0, this uses JSON Schema 2020-12.
    • Upgrade Swagger UI to version 5.x.x, that supports OpenAPI 3.1.0.
    • Updated examples field in Query(), Cookie(), Body(), etc. based on the latest JSON Schema and OpenAPI. Now it takes a list of examples and they are included directly in the JSON Schema, not outside. Read more about it (including the historical technical details) in the updated docs: Tutorial: Declare Request Example Data.
  • ✨ Add support for deque objects and children in jsonable_encoder. PR #​9433 by @​cranium.

Docs
Translations
Internal

v0.98.0

Compare Source

Note: please also help me try out the beta with support for Pydantic v2: https://github.com/tiangolo/fastapi/releases/tag/0.100.0-beta1

Now, back to this release (this one doesn't include the beta support for Pydantic v2).

Features
Docs
Translations
Internal

v0.97.0

Compare Source

Features
Refactors
  • ⬆️ Upgrade and fully migrate to Ruff, remove isort, includes a couple of tweaks suggested by the new version of Ruff. PR #​9660 by @​tiangolo.
  • ♻️ Update internal type annotations and upgrade mypy. PR #​9658 by @​tiangolo.
  • ♻️ Simplify AsyncExitStackMiddleware as without Python 3.6 AsyncExitStack is always available. PR #​9657 by @​tiangolo.
Upgrades
Internal
  • 💚 Update CI cache to fix installs when dependencies change. PR #​9659 by @​tiangolo.
  • ⬇️ Separate requirements for development into their own requirements.txt files, they shouldn't be extras. PR #​9655 by @​tiangolo.

v0.96.1

Compare Source

Fixes
Upgrades
  • 📌 Update minimum version of Pydantic to >=1.7.4. This fixes an issue when trying to use an old version of Pydantic. PR #​9567 by @​Kludex.
Refactors
  • ♻ Remove media_type from ORJSONResponse as it's inherited from the parent class. PR #​5805 by @​Kludex.
  • ♻ Instantiate HTTPException only when needed, optimization refactor. PR #​5356 by @​pawamoy.
Docs
  • 🔥 Remove link to Pydantic's benchmark, as it was removed there. PR #​5811 by @​Kludex.
Translations
  • 🌐 Fix spelling in Indonesian translation of docs/id/docs/tutorial/index.md. PR #​5635 by @​purwowd.
  • 🌐 Add Russian translation for docs/ru/docs/tutorial/index.md. PR #​5896 by @​Wilidon.
  • 🌐 Add Chinese translations for docs/zh/docs/advanced/response-change-status-code.md and docs/zh/docs/advanced/response-headers.md. PR #​9544 by @​ChoyeonChern.
  • 🌐 Add Russian translation for docs/ru/docs/tutorial/schema-extra-example.md. PR #​9621 by @​Alexandrhub.
Internal

v0.96.0

Compare Source

Features
  • ⚡ Update create_cloned_field to use a global cache and improve startup performance. PR #​4645 by @​madkinsz and previous original PR by @​huonw.
Docs
Translations
  • 🌐 Add Russian translation for docs/tutorial/body.md. PR #​3885 by @​solomein-sv.
  • 🌐 Add Russian translation for docs/ru/docs/tutorial/static-files.md. PR #​9580 by @​Alexandrhub.
  • 🌐 Add Russian translation for docs/ru/docs/tutorial/query-params.md. PR #​9584 by @​Alexandrhub.
  • 🌐 Add Russian translation for docs/ru/docs/tutorial/first-steps.md. PR #​9471 by @​AGolicyn.
  • 🌐 Add Russian translation for docs/ru/docs/tutorial/debugging.md. PR [#​9579

Configuration

📅 Schedule: Branch creation - "after 9pm,before 5am" (UTC), 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.

👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@renovate renovate bot force-pushed the renovate/beta branch 2 times, most recently from 41dc854 to 389c0e4 Compare November 4, 2022 18:35
@renovate renovate bot changed the title fix(deps): update dependency fastapi to v0.86.0 fix(deps): update dependency fastapi to v0.86.0 - autoclosed Nov 4, 2022
@renovate renovate bot closed this Nov 4, 2022
@renovate renovate bot deleted the renovate/beta branch November 4, 2022 18:36
@renovate renovate bot changed the title fix(deps): update dependency fastapi to v0.86.0 - autoclosed fix(deps): update dependency fastapi to v0.86.0 Nov 7, 2022
@renovate renovate bot reopened this Nov 7, 2022
@renovate renovate bot restored the renovate/beta branch November 7, 2022 11:49
@renovate renovate bot changed the title fix(deps): update dependency fastapi to v0.86.0 fix(deps): update dependency databases to v0.6.2 Nov 7, 2022
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@renovate renovate bot changed the title fix(deps): update dependency databases to v0.6.2 fix(deps): update beta Nov 13, 2022
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@renovate renovate bot changed the title fix(deps): update beta fix(deps): update dependency fastapi to v0.87.0 Nov 15, 2022
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@renovate renovate bot changed the title fix(deps): update dependency fastapi to v0.87.0 fix(deps): update dependency fastapi to v0.88.0 Nov 27, 2022
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants