]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commit
:sparkles: Add dependencies with yield (used as context managers) (#595)
authorSebastián Ramírez <tiangolo@gmail.com>
Wed, 9 Oct 2019 18:01:58 +0000 (13:01 -0500)
committerGitHub <noreply@github.com>
Wed, 9 Oct 2019 18:01:58 +0000 (13:01 -0500)
commit3f9f4a0f8f7f5db50fbdc3157fe692cf4e68e13f
tree79b3ab9bc79219e1af79a8f0e68eb134789d5bfa
parent380e3731a8dc3297a7ae14e6e00fe6874af1b18f
:sparkles: Add dependencies with yield (used as context managers) (#595)

* :heavy_plus_sign: Add development/testing dependencies for Python 3.6

* :sparkles: Add concurrency submodule with contextmanager_in_threadpool

* :sparkles: Add AsyncExitStack to ASGI scope in FastAPI app call

* :sparkles: Use async stack for contextmanager-able dependencies

including running in threadpool sync dependencies

* :white_check_mark: Add tests for contextmanager dependencies

including internal raise checks when exceptions should be handled and when not

* :white_check_mark: Add test for fake asynccontextmanager raiser

* :bug: Fix mypy errors and coverage

* :mute: Remove development logs and prints

* :white_check_mark: Add tests for sub-contextmanagers, background tasks, and sync functions

* :bug: Fix mypy errors for Python 3.7

* :speech_balloon: Fix error texts for clarity

* :memo: Add docs for dependencies with yield

* :sparkles: Update SQL with SQLAlchemy tutorial to use dependencies with yield

and add an alternative with a middleware (from the old tutorial)

* :white_check_mark: Update SQL tests to remove DB file during the same tests

* :white_check_mark: Add tests for example with middleware

as a copy from the tests with dependencies with yield, removing the DB in the tests

* :pencil2: Fix typos with suggestions from code review

Co-Authored-By: dmontagu <35119617+dmontagu@users.noreply.github.com>
19 files changed:
docs/src/dependencies/tutorial007.py
docs/src/dependencies/tutorial008.py [new file with mode: 0644]
docs/src/dependencies/tutorial009.py [new file with mode: 0644]
docs/src/dependencies/tutorial010.py [new file with mode: 0644]
docs/src/dependencies/tutorial011.py [new file with mode: 0644]
docs/src/sql_databases/sql_app/alt_main.py [new file with mode: 0644]
docs/src/sql_databases/sql_app/main.py
docs/tutorial/dependencies/advanced-dependencies.md
docs/tutorial/dependencies/dependencies-with-yield.md [new file with mode: 0644]
docs/tutorial/sql-databases.md
fastapi/applications.py
fastapi/concurrency.py [new file with mode: 0644]
fastapi/dependencies/utils.py
mkdocs.yml
pyproject.toml
tests/test_dependency_contextmanager.py [new file with mode: 0644]
tests/test_fakeasync.py [new file with mode: 0644]
tests/test_tutorial/test_sql_databases/test_sql_databases.py
tests/test_tutorial/test_sql_databases/test_sql_databases_middleware.py [new file with mode: 0644]