fix(ci): restore green backend CI — ruff config + unused import cleanup #117

Merged
pyr0ball merged 6 commits from fix/ci-ruff-lint into main 2026-05-21 12:05:51 -07:00
Owner

Problem

The backend Python CI job has been failing on every push since April. Root cause: ruff found lint violations in files that were never covered by a ruff config.

What was failing

File Violation Cause
app/app.py E402, F401 Deprecated Streamlit app — intentional env-load-first pattern
dev-api.py E702 Compact Pydantic model field definitions (intentional style)
dev-api.py E402 Mid-file imports documented with explaining comments
dev-api.py F841 Dead db_path_obj variable (genuine dead code — fixed)
scripts/finetune_local.py E402 Conditional ML imports after CUDA check
tests/ F841 Mock-patch capture variables (standard testing pattern)

Fixes

  1. pyproject.toml (new): ruff config with targeted per-file-ignores — suppresses intentional violations, documents why each exception exists
  2. dev-api.py: removes dead db_path_obj assignment; adds # noqa: E402 to two documented mid-file imports
  3. scripts/finetune_local.py: renames ambiguous lline
  4. tools/label_tool.py: renames ambiguous llbl
  5. Ruff auto-fix: removes verified-unused imports across 60 files (scripts/, tests/, scrapers/)

Remaining CI failures (NOT fixed in this PR)

  • mirror.ymlGITHUB_MIRROR_TOKEN and CODEBERG_MIRROR_TOKEN secrets not configured in Forgejo
  • release.ymlFORGEJO_RELEASE_TOKEN secret not configured (tags v0.9.1–v0.9.7 all missing releases)

These require secrets to be added in Forgejo → Settings → Actions → Secrets.

Tests

807 passed, 2 skipped locally.

## Problem The backend Python CI job has been failing on every push since April. Root cause: ruff found lint violations in files that were never covered by a ruff config. ## What was failing | File | Violation | Cause | |------|-----------|-------| | `app/app.py` | E402, F401 | Deprecated Streamlit app — intentional env-load-first pattern | | `dev-api.py` | E702 | Compact Pydantic model field definitions (intentional style) | | `dev-api.py` | E402 | Mid-file imports documented with explaining comments | | `dev-api.py` | F841 | Dead `db_path_obj` variable (genuine dead code — fixed) | | `scripts/finetune_local.py` | E402 | Conditional ML imports after CUDA check | | tests/ | F841 | Mock-patch capture variables (standard testing pattern) | ## Fixes 1. **`pyproject.toml`** (new): ruff config with targeted `per-file-ignores` — suppresses intentional violations, documents why each exception exists 2. **`dev-api.py`**: removes dead `db_path_obj` assignment; adds `# noqa: E402` to two documented mid-file imports 3. **`scripts/finetune_local.py`**: renames ambiguous `l` → `line` 4. **`tools/label_tool.py`**: renames ambiguous `l` → `lbl` 5. **Ruff auto-fix**: removes verified-unused imports across 60 files (scripts/, tests/, scrapers/) ## Remaining CI failures (NOT fixed in this PR) - `mirror.yml` — `GITHUB_MIRROR_TOKEN` and `CODEBERG_MIRROR_TOKEN` secrets not configured in Forgejo - `release.yml` — `FORGEJO_RELEASE_TOKEN` secret not configured (tags v0.9.1–v0.9.7 all missing releases) These require secrets to be added in Forgejo → Settings → Actions → Secrets. ## Tests 807 passed, 2 skipped locally.
pyr0ball added 3 commits 2026-05-20 23:08:28 -07:00
- Add pyproject.toml with ruff per-file-ignores:
  - Exclude deprecated app/ Streamlit dir entirely
  - Suppress E702 in dev-api.py (intentional compact Pydantic models)
  - Suppress E402 in finetune_local.py (conditional ML imports after CUDA check)
  - Suppress F841/E741/E702 in tests/ (mock-patch capture pattern)
- Remove unused db_path_obj assignment in dev-api.py:760
- Add # noqa: E402 to documented mid-file imports in dev-api.py
- Rename ambiguous l variable to line/lbl in finetune_local.py + label_tool.py
Removes unused imports flagged by ruff F401 across 12 scripts.
All removals are safe — ruff only auto-fixes imports that are verifiably unused.
chore(lint): ruff auto-fix unused imports in tests/
Some checks failed
CI / Backend (Python) (push) Failing after 30s
CI / Frontend (Vue) (push) Successful in 22s
CI / Backend (Python) (pull_request) Failing after 27s
CI / Frontend (Vue) (pull_request) Successful in 20s
e87c707dd9
Removes unused imports flagged by ruff F401 across 47 test files.
Auto-fix only — imports verified unused by static analysis.
pyr0ball added 1 commit 2026-05-21 11:41:13 -07:00
fix(ci): rename GITHUB_MIRROR_TOKEN secret to GH_MIRROR_TOKEN
Some checks failed
CI / Backend (Python) (push) Failing after 26s
CI / Frontend (Vue) (push) Successful in 22s
CI / Backend (Python) (pull_request) Failing after 22s
CI / Frontend (Vue) (pull_request) Successful in 20s
46bae7db1c
Forgejo reserves the GITHUB_* prefix for secret names — creating a secret
called GITHUB_MIRROR_TOKEN returns 'invalid secret name'.
Also rename the GITHUB_TOKEN step env var to GH_MIRROR_PAT to avoid
collision with the built-in Forgejo Actions context variable.
pyr0ball added 1 commit 2026-05-21 11:51:43 -07:00
fix(ci): restore TaskSpec re-export in task_scheduler.py
Some checks failed
CI / Backend (Python) (push) Failing after 31s
CI / Frontend (Vue) (push) Successful in 22s
CI / Backend (Python) (pull_request) Failing after 23s
CI / Frontend (Vue) (pull_request) Successful in 20s
e4c5744d87
ruff --fix removed the TaskSpec import as unused within the module,
but it is part of the public API — tests import it from scripts.task_scheduler
rather than reaching into circuitforge_core directly.
Add # noqa: F401 to protect intentional re-exports from future auto-fix.
pyr0ball added 1 commit 2026-05-21 12:03:48 -07:00
fix(ci): install ruff before lint step
All checks were successful
CI / Backend (Python) (push) Successful in 1m33s
CI / Frontend (Vue) (push) Successful in 19s
CI / Backend (Python) (pull_request) Successful in 1m21s
CI / Frontend (Vue) (pull_request) Successful in 19s
02d79e6727
ruff is not in requirements.txt (dev-only tool) so the CI runner
couldn't find it. Install explicitly in the workflow.
pyr0ball merged commit 11aee888be into main 2026-05-21 12:05:51 -07:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Circuit-Forge/peregrine#117
No description provided.