From 475a2cdc3c5a008289fa17ba7e90399015f1cce3 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Mon, 31 Aug 2026 20:14:39 +0000 Subject: [PATCH] Cleaner and non-deprecated typing for template app module. Avoids ruff errors with strict configurations. --- fastapi_vue_setup.py | 2 +- template/backend/app.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fastapi_vue_setup.py b/fastapi_vue_setup.py index 76b9941..d602948 100644 --- a/fastapi_vue_setup.py +++ b/fastapi_vue_setup.py @@ -166,7 +166,7 @@ frontend = Frontend(Path(__file__).with_name("frontend-build")) # Lifespan block for patching apps that don't have one LIFESPAN_BLOCK = """ @asynccontextmanager -async def lifespan(app: FastAPI): +async def lifespan(_app: FastAPI): \"\"\"Manage app startup and shutdown resources.\"\"\" await frontend.load() yield diff --git a/template/backend/app.py b/template/backend/app.py index d5e3e46..f14b493 100644 --- a/template/backend/app.py +++ b/template/backend/app.py @@ -1,6 +1,6 @@ """FastAPI application module with Vue frontend integration.""" -from collections.abc import AsyncIterator +from collections.abc import AsyncGenerator from contextlib import asynccontextmanager from pathlib import Path @@ -13,7 +13,7 @@ frontend = Frontend(Path(__file__).with_name("frontend-build")) @asynccontextmanager -async def lifespan(_app: FastAPI) -> AsyncIterator[None]: +async def lifespan(_app: FastAPI) -> AsyncGenerator: """Manage app startup and shutdown resources.""" await frontend.load() yield @@ -27,7 +27,7 @@ app = FastAPI(title="PROJECT_TITLE", debug=DEVMODE, lifespan=lifespan) # Health check endpoint for the Vue demo app to verify the backend is running @app.get("/api/health") -async def health_check() -> dict[str, str]: +async def health_check() -> dict: """Return backend status for health monitoring.""" return {"status": "ok"}