refactor: enhance type hinting and casting for improved type safety across multiple files

This commit is contained in:
Artem Kashaev
2025-12-01 16:44:14 +05:00
parent f234e60e65
commit 688ade0452
14 changed files with 62 additions and 42 deletions
+4 -3
View File
@@ -4,6 +4,7 @@ from __future__ import annotations
from collections.abc import Sequence
from dataclasses import dataclass
from typing import cast
from sqlalchemy import select
@@ -151,11 +152,11 @@ class ContactService:
def _build_update_mapping(self, updates: ContactUpdateData) -> dict[str, str | None]:
payload: dict[str, str | None] = {}
if updates.name is not UNSET:
payload["name"] = updates.name
payload["name"] = cast(str | None, updates.name)
if updates.email is not UNSET:
payload["email"] = updates.email
payload["email"] = cast(str | None, updates.email)
if updates.phone is not UNSET:
payload["phone"] = updates.phone
payload["phone"] = cast(str | None, updates.phone)
return payload
async def _ensure_no_related_deals(self, contact_id: int) -> None: