add dep user in db, fix typecheck

This commit is contained in:
IluaAir
2025-06-22 12:01:04 +03:00
parent 1951260788
commit 05121b3d06
2 changed files with 10 additions and 4 deletions

View File

@@ -1,14 +1,20 @@
from typing import Annotated
from typing import Annotated, AsyncGenerator
from fastapi import Depends
from fastapi_users_db_sqlalchemy import SQLAlchemyUserDatabase
from sqlalchemy.ext.asyncio import AsyncSession
from src.db.database import async_session_maker
from src.models import UsersORM
async def get_db():
async def get_db() -> AsyncGenerator[AsyncSession, None]:
async with async_session_maker as db:
yield db
DBDep = Annotated[AsyncSession, Depends(get_db)]
async def get_user_db(session: DBDep):
yield SQLAlchemyUserDatabase(session, UsersORM)