refactor: using optional keyword
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
from typing import Optional
|
||||
|
||||
from sqlalchemy import select
|
||||
|
||||
from models import Board
|
||||
@ -13,7 +15,7 @@ class BoardRepository(BaseRepository):
|
||||
result = await self.session.execute(stmt)
|
||||
return list(result.scalars().all())
|
||||
|
||||
async def get_by_id(self, board_id: int) -> Board | None:
|
||||
async def get_by_id(self, board_id: int) -> Optional[Board]:
|
||||
stmt = select(Board).where(Board.id == board_id, Board.is_deleted.is_(False))
|
||||
result = await self.session.execute(stmt)
|
||||
return result.scalar_one_or_none()
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
from typing import Optional
|
||||
|
||||
from sqlalchemy import select
|
||||
|
||||
from models import Status
|
||||
@ -7,14 +9,13 @@ from schemas.status import UpdateStatusSchema
|
||||
|
||||
class StatusRepository(BaseRepository):
|
||||
async def get_all(self, board_id: int) -> list[Status]:
|
||||
stmt = (
|
||||
select(Status)
|
||||
.where(Status.is_deleted.is_(False), Status.board_id == board_id)
|
||||
stmt = select(Status).where(
|
||||
Status.is_deleted.is_(False), Status.board_id == board_id
|
||||
)
|
||||
result = await self.session.execute(stmt)
|
||||
return list(result.scalars().all())
|
||||
|
||||
async def get_by_id(self, status_id: int) -> Status | None:
|
||||
async def get_by_id(self, status_id: int) -> Optional[Status]:
|
||||
stmt = select(Status).where(
|
||||
Status.id == status_id, Status.is_deleted.is_(False)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user