This commit is contained in:
Saeid Noormohammadi 2026-02-17 10:01:25 +00:00 committed by GitHub
commit 2b948d8f0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 0 deletions

View File

@ -513,6 +513,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[
Sequence[Callable[[], Any]] | None,
@ -526,6 +534,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[
Lifespan[AppType] | None,

View File

@ -876,6 +876,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[
Sequence[Callable[[], Any]] | None,
@ -889,6 +897,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