fix(video): type _override_db yield as AsyncSession | None

T7 widened _build_app's db_session param to AsyncSession | None (to drop the
4x # type: ignore[arg-type] on the DB-independent _build_app(None, ...) calls)
but left the inner _override_db fixture typed AsyncIterator[AsyncSession] —
so 'yield db_session' yielded AsyncSession | None into a declared AsyncSession,
and mypy failed at test_video_routes.py:177 ('Incompatible types in yield').

The DB-independent media tests pass db_session=None deliberately: their route
uses a monkeypatched task service and never awaits the session, so yielding
None is safe at runtime. Type the override's yield as AsyncSession | None to
match — no cast, no # type: ignore, no assert, runtime behavior unchanged.
The 3 media tests (3 passed) and the 19 db-gated tests (skipped locally) hold.
This commit is contained in:
Renn F
2026-07-06 03:05:23 +02:00
parent 9124c5836d
commit 33eeeddd7d
+4 -1
View File
@@ -173,7 +173,10 @@ def _build_app(
app.include_router(video_router, prefix="/api/video") app.include_router(video_router, prefix="/api/video")
app.include_router(tiktok_router, prefix="/api/tiktok") app.include_router(tiktok_router, prefix="/api/tiktok")
async def _override_db() -> AsyncIterator[AsyncSession]: async def _override_db() -> AsyncIterator[AsyncSession | None]:
# DB-independent tests pass db_session=None and monkeypatch the task
# service so the route never awaits the session — yielding None is
# safe because the route body uses the patched service, not get_db.
yield db_session yield db_session
async def _override_agent() -> AgentContext: async def _override_agent() -> AgentContext: