refactor: using optional keyword

This commit is contained in:
2025-08-05 17:06:46 +04:00
parent 5db5f116af
commit ab1d066fdd
8 changed files with 31 additions and 18 deletions

View File

@ -1,3 +1,5 @@
from typing import Optional
from sqlalchemy import select
from models import Deal
@ -11,7 +13,7 @@ class DealRepository(BaseRepository):
result = await self.session.execute(stmt)
return list(result.scalars().all())
async def get_by_id(self, deal_id: int) -> Deal | None:
async def get_by_id(self, deal_id: int) -> Optional[Deal]:
stmt = select(Deal).where(Deal.id == deal_id, Deal.is_deleted.is_(False))
result = await self.session.execute(stmt)
return result.scalar_one_or_none()