-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Description
_api_post and _api_post_form in api_client.py use the bare dict type for their data parameter without generic arguments:
def _api_post(client: httpx.Client, url: str, data: dict) -> httpx.Response:
...
def _api_post_form(client: httpx.Client, url: str, data: dict) -> httpx.Response:
...The repository uses mypy for static type checking (CI enforced via .github/workflows/typecheck.yml). A bare dict annotation without generics is equivalent to dict[Any, Any], which is less precise than the actual usage where callers always pass dict[str, Any] (string keys, mixed values). Tightening these annotations:
- Makes mypy's inference more accurate for callers that pass typed dicts
- Documents the expected shape of the
dataparameter for future maintainers - Is consistent with the existing pattern in the codebase (e.g.,
_api_stats: dict[str, int],_disk_cache: dict[str, dict[str, Any]]— all using explicit generics)
No other functions exported from api_client.__all__ use bare dict.
Suggested Changes
In api_client.py, update both function signatures:
# Before
def _api_post(client: httpx.Client, url: str, data: dict) -> httpx.Response:
# After
def _api_post(client: httpx.Client, url: str, data: dict[str, Any]) -> httpx.Response:# Before
def _api_post_form(client: httpx.Client, url: str, data: dict) -> httpx.Response:
# After
def _api_post_form(client: httpx.Client, url: str, data: dict[str, Any]) -> httpx.Response:Any is already imported at the top of api_client.py (via from typing import Any, Callable).
Files Affected
api_client.py— update 2 function signatures (lines ~314, ~320)
Success Criteria
- ✅ Both function signatures use
dict[str, Any]for thedataparameter - ✅
uv run mypy api_client.pyexits clean - ✅ All existing tests pass:
uv run pytest tests/ -v - ✅ No caller changes needed (callers already pass
dict[str, Any]-compatible dicts)
Source
Identified while reviewing api_client.py module structure in context of the Daily Backlog Burner discussion #493 modularization and type-quality theme. Consistent with the repository's use of mypy in CI and explicit generic annotations throughout both api_client.py and cache.py.
Priority
Low — 2-line change. Improves type precision and mypy signal quality.
🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent
To install this agentic workflow, run
gh aw add github/gh-aw/.github/workflows/discussion-task-miner.md@94662b1dee8ce96c876ba9f33b3ab8be32de82a4
- expires on Mar 6, 2026, 9:14 AM UTC