-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Description
api_client.py (extracted from main.py as part of the modularization effort in #473/#516) has a stdlib-after-third-party import ordering violation:
# api_client.py lines 31–32 (current — incorrect order)
import httpx # third-party
import contextlib # stdlib — should come BEFORE third-party importsPEP 8 and isort require: stdlib → third-party → local. The current ruff config (pyproject.toml) selects E, W, F, RET, SIM, UP but not I (isort), so this violation is not caught by CI today.
Adding "I" to the ruff select list and fixing the violation ensures consistent import ordering is automatically enforced across all current and future modules (config.py, validation.py, etc.).
Suggested Changes
- Fix
api_client.py— moveimport contextlibbeforeimport httpx:
from __future__ import annotations
import contextlib # ← move here (stdlib section)
import logging
import random
import threading
import time
from collections.abc import Callable
from typing import Any
import httpx # ← third-party stays here- Update
pyproject.toml— add"I"to the ruffselectlist:
[tool.ruff.lint]
select = [
"E",
"W",
"F",
"I", # ← add isort
"RET",
"SIM",
"UP",
]- Verify no other violations introduced by the new rule:
uv tool run ruff check . --select I
uv tool run ruff check . --select I --fix # auto-fixableFiles Affected
api_client.py— reorderimport contextlibinto the stdlib blockpyproject.toml— add"I"to[tool.ruff.lint] select
Success Criteria
- ✅
api_client.py:import contextlibprecedesimport httpx - ✅
"I"appears in[tool.ruff.lint] selectinpyproject.toml - ✅
uv tool run ruff check . --select Iexits clean - ✅ All existing tests pass:
uv run pytest tests/ -v
Source
Import ordering violation observed during code review of the modularization output (Daily Backlog Burner discussion #493 — staged extraction of api_client.py, cache.py, validation.py). Complements the B (flake8-bugbear) rule addition in #543.
Priority
Low — 2-line fix + 1-line config change. The I rule is auto-fixable and prevents future import ordering drift as more modules are extracted from main.py.
🔍 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 5, 2026, 1:41 PM UTC