From 9846605462a2810b32855ac3f9e6724bfa994ac2 Mon Sep 17 00:00:00 2001 From: heysaeid Date: Tue, 14 Nov 2023 17:52:00 +0330 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=93=9D=20Update=20documentation=20for?= =?UTF-8?q?=20deprecated=20on=5Fstartup=20and=20on=5Fshutdown=20parameters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastapi/applications.py | 16 ++++++++++++++++ fastapi/routing.py | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/fastapi/applications.py b/fastapi/applications.py index 3021d7593..582e9765c 100644 --- a/fastapi/applications.py +++ b/fastapi/applications.py @@ -515,6 +515,14 @@ class FastAPI(Starlette): Read more in the [FastAPI docs for `lifespan`](https://fastapi.tiangolo.com/advanced/events/). """ ), + deprecated( + """ + **Attention**: This parameter is deprecated. + + The recommended approach for managing startup and shutdown + is by utilizing the lifespan parameter within the FastAPI app. + """ + ), ] = None, on_shutdown: Annotated[ Optional[Sequence[Callable[[], Any]]], @@ -528,6 +536,14 @@ class FastAPI(Starlette): [FastAPI docs for `lifespan`](https://fastapi.tiangolo.com/advanced/events/). """ ), + deprecated( + """ + **Attention**: This parameter is deprecated. + + The recommended approach for managing startup and shutdown + is by utilizing the lifespan parameter within the FastAPI app. + """ + ), ] = None, lifespan: Annotated[ Optional[Lifespan[AppType]], diff --git a/fastapi/routing.py b/fastapi/routing.py index 54d53bbbf..2082ab0ab 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -690,6 +690,14 @@ class APIRouter(routing.Router): Read more in the [FastAPI docs for `lifespan`](https://fastapi.tiangolo.com/advanced/events/). """ ), + deprecated( + """ + **Attention**: This parameter is deprecated. + + The recommended approach for managing startup and shutdown + is by utilizing the lifespan parameter within the APIRouter. + """ + ), ] = None, on_shutdown: Annotated[ Optional[Sequence[Callable[[], Any]]], @@ -703,6 +711,14 @@ class APIRouter(routing.Router): [FastAPI docs for `lifespan`](https://fastapi.tiangolo.com/advanced/events/). """ ), + deprecated( + """ + **Attention**: This parameter is deprecated. + + The recommended approach for managing startup and shutdown + is by utilizing the lifespan parameter within the APIRouter. + """ + ), ] = None, # the generic to Lifespan[AppType] is the type of the top level application # which the router cannot know statically, so we use typing.Any From 0c81a76fdf7d01672f32e713762b02929eff4913 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 14 Nov 2023 14:27:41 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=8E=A8=20[pre-commit.ci]=20Auto=20for?= =?UTF-8?q?mat=20from=20pre-commit.com=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastapi/applications.py | 4 ++-- fastapi/routing.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fastapi/applications.py b/fastapi/applications.py index 582e9765c..443045375 100644 --- a/fastapi/applications.py +++ b/fastapi/applications.py @@ -519,7 +519,7 @@ class FastAPI(Starlette): """ **Attention**: This parameter is deprecated. - The recommended approach for managing startup and shutdown + The recommended approach for managing startup and shutdown is by utilizing the lifespan parameter within the FastAPI app. """ ), @@ -540,7 +540,7 @@ class FastAPI(Starlette): """ **Attention**: This parameter is deprecated. - The recommended approach for managing startup and shutdown + The recommended approach for managing startup and shutdown is by utilizing the lifespan parameter within the FastAPI app. """ ), diff --git a/fastapi/routing.py b/fastapi/routing.py index 2082ab0ab..b42f7b9b3 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -694,7 +694,7 @@ class APIRouter(routing.Router): """ **Attention**: This parameter is deprecated. - The recommended approach for managing startup and shutdown + The recommended approach for managing startup and shutdown is by utilizing the lifespan parameter within the APIRouter. """ ), @@ -715,7 +715,7 @@ class APIRouter(routing.Router): """ **Attention**: This parameter is deprecated. - The recommended approach for managing startup and shutdown + The recommended approach for managing startup and shutdown is by utilizing the lifespan parameter within the APIRouter. """ ),