Skip to content

docs: replace deprecated on_event with lifespan in py310 tutorials#1911

Closed
Harshvardhan-M wants to merge 2 commits into
fastapi:mainfrom
Harshvardhan-M:main
Closed

docs: replace deprecated on_event with lifespan in py310 tutorials#1911
Harshvardhan-M wants to merge 2 commits into
fastapi:mainfrom
Harshvardhan-M:main

Conversation

@Harshvardhan-M
Copy link
Copy Markdown

Fixes #958

Replaces the deprecated @app.on_event("startup") pattern with the
modern lifespan context manager across all py310 tutorial examples.

Changes:

  • Added from contextlib import asynccontextmanager import to 13 files
  • Replaced @app.on_event("startup") with @asynccontextmanager lifespan
  • Updated FastAPI() to FastAPI(lifespan=lifespan) in all affected files

Files changed:

  • app_testing, delete, limit_and_offset, multiple_models (x2), read_one,
    relationships, response_model, session_with_dependency, simple_hero_api,
    teams, update (x2)

@github-actions github-actions Bot added the docs Improvements or additions to documentation label May 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📝 Docs preview

Last commit 2f5af2e at: https://b4cac498.sqlmodel.pages.dev

@YuriiMotov YuriiMotov added the invalid This doesn't seem right label May 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This was marked as invalid and will be closed now. If this is an error, please provide additional details.

@github-actions github-actions Bot closed this May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants