refactor: enhance type hinting and casting for improved type safety across multiple files
This commit is contained in:
@@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
from collections.abc import Mapping, Sequence
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
from typing import Any, cast
|
||||
|
||||
from sqlalchemy import Select, select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
@@ -123,6 +123,9 @@ class TaskRepository:
|
||||
|
||||
async def _resolve_task_owner(self, task: Task) -> int | None:
|
||||
if task.deal is not None:
|
||||
return task.deal.owner_id
|
||||
return int(task.deal.owner_id)
|
||||
stmt = select(Deal.owner_id).where(Deal.id == task.deal_id)
|
||||
return await self._session.scalar(stmt)
|
||||
owner_id_raw: Any = await self._session.scalar(stmt)
|
||||
if owner_id_raw is None:
|
||||
return None
|
||||
return cast(int, owner_id_raw)
|
||||
|
||||
Reference in New Issue
Block a user