no-fastapi-on-event
Deprecated FastAPI or Starlette on_event lifecycle registration.
Why
The on_event API is deprecated and splits related startup and shutdown state across callbacks; lifespan keeps acquisition and cleanup in one async context manager and is the supported lifecycle contract.
Fix
Define an async lifespan context manager and pass it as FastAPI(lifespan=...) or Starlette(lifespan=...).
Examples
from fastapi import FastAPI
app = FastAPI()
@app.on_event("startup")async def start() -> None: passfrom contextlib import asynccontextmanagerfrom fastapi import FastAPI
@asynccontextmanagerasync def lifespan(app: FastAPI): yield
app = FastAPI(lifespan=lifespan)