mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
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:
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user