fix: mypy for github approval check services

This commit is contained in:
Abhimanyu Saharan
2026-02-15 05:58:17 +00:00
parent 0c6c093736
commit f3e7c6b67e
2 changed files with 8 additions and 5 deletions

View File

@@ -83,13 +83,14 @@ async def get_pull_request_head_sha(pr: ParsedPullRequest) -> str:
head = data.get("head") head = data.get("head")
if not isinstance(head, dict) or not isinstance(head.get("sha"), str): if not isinstance(head, dict) or not isinstance(head.get("sha"), str):
raise GitHubClientError("GitHub PR response missing head.sha") raise GitHubClientError("GitHub PR response missing head.sha")
return head["sha"] # mypy: dict indexing returns Any; we've validated it's a str above.
return str(head["sha"])
async def _find_check_run_id(*, owner: str, repo: str, ref: str, check_name: str) -> int | None: async def _find_check_run_id(*, owner: str, repo: str, ref: str, check_name: str) -> int | None:
# Docs: GET /repos/{owner}/{repo}/commits/{ref}/check-runs # Docs: GET /repos/{owner}/{repo}/commits/{ref}/check-runs
url = f"{GITHUB_API_BASE_URL}/repos/{owner}/{repo}/commits/{ref}/check-runs" url = f"{GITHUB_API_BASE_URL}/repos/{owner}/{repo}/commits/{ref}/check-runs"
params = {"check_name": check_name, "per_page": 100} params: dict[str, str | int] = {"check_name": check_name, "per_page": 100}
async with httpx.AsyncClient(timeout=10) as client: async with httpx.AsyncClient(timeout=10) as client:
resp = await client.get(url, headers=_auth_headers(), params=params) resp = await client.get(url, headers=_auth_headers(), params=params)
if resp.status_code >= 400: if resp.status_code >= 400:

View File

@@ -21,7 +21,7 @@ A periodic reconciliation job should call the sync functions as a safety net.
from __future__ import annotations from __future__ import annotations
from dataclasses import dataclass from dataclasses import dataclass
from typing import Literal from typing import Literal, cast
from uuid import UUID from uuid import UUID
from sqlmodel import col, select from sqlmodel import col, select
@@ -360,7 +360,8 @@ async def reconcile_github_approval_checks_for_board(
.where(col(TaskCustomFieldDefinition.organization_id) == org_id) .where(col(TaskCustomFieldDefinition.organization_id) == org_id)
.where(col(TaskCustomFieldDefinition.field_key) == "github_pr_url") .where(col(TaskCustomFieldDefinition.field_key) == "github_pr_url")
) )
rows = list(await session.exec(stmt)) raw_rows = list(await session.exec(stmt))
rows = cast(list[tuple[object]], raw_rows)
pr_urls: set[str] = set() pr_urls: set[str] = set()
for (value,) in rows: for (value,) in rows:
@@ -383,11 +384,12 @@ async def reconcile_mission_control_approval_checks_for_all_boards() -> int:
""" """
async with async_session_maker() as session: async with async_session_maker() as session:
board_ids = list( raw_board_ids = list(
await session.exec( await session.exec(
select(col(Board.id)).order_by(col(Board.created_at).asc()), select(col(Board.id)).order_by(col(Board.created_at).asc()),
), ),
) )
board_ids = cast(list[UUID], raw_board_ids)
processed = 0 processed = 0
for board_id in board_ids: for board_id in board_ids:
try: try: