fix: mypy for github approval check services
This commit is contained in:
@@ -83,13 +83,14 @@ async def get_pull_request_head_sha(pr: ParsedPullRequest) -> str:
|
||||
head = data.get("head")
|
||||
if not isinstance(head, dict) or not isinstance(head.get("sha"), str):
|
||||
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:
|
||||
# Docs: GET /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:
|
||||
resp = await client.get(url, headers=_auth_headers(), params=params)
|
||||
if resp.status_code >= 400:
|
||||
|
||||
@@ -21,7 +21,7 @@ A periodic reconciliation job should call the sync functions as a safety net.
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Literal
|
||||
from typing import Literal, cast
|
||||
from uuid import UUID
|
||||
|
||||
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.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()
|
||||
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:
|
||||
board_ids = list(
|
||||
raw_board_ids = list(
|
||||
await session.exec(
|
||||
select(col(Board.id)).order_by(col(Board.created_at).asc()),
|
||||
),
|
||||
)
|
||||
board_ids = cast(list[UUID], raw_board_ids)
|
||||
processed = 0
|
||||
for board_id in board_ids:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user