Skip to content

chore: adopt ruff linter (check-only) + fix two latent bugs it surfaced - #148

Merged
jramos merged 1 commit into
mainfrom
chore/ruff-check-adoption
Jun 29, 2026
Merged

chore: adopt ruff linter (check-only) + fix two latent bugs it surfaced#148
jramos merged 1 commit into
mainfrom
chore/ruff-check-adoption

Conversation

@jramos

@jramos jramos commented Jun 29, 2026

Copy link
Copy Markdown
Owner

What

Adopts ruff as a linter (check-only; the formatter stays deferred) — the ruff follow-up noted under the #106 disposition. Measured the tree first, then adopted only the high-value half.

Numbers (measured before adopting)

ruff check (linter) ruff format (formatter)
Footprint 134 findings, 79 auto-fixable 169/225 files, +10.8k/−4.5k lines
Nature real issues (dead imports, empty f-strings, 2 latent bugs) pure cosmetic reflow
Decision adopt defer

The #106 deferral blocker ("needs a line-length policy first") is real: the tree is written to ~100 chars (1208 lines > 88, but only 318 > 100). So E501 is intentionally not selected, and a one-shot line-length = 100 reformat (recorded in .git-blame-ignore-revs) remains the separate, optional path.

Two genuine latent bugs the linter caught

  • evolution/tools/tool_module.pyOptional used in an annotation but never imported (F821), masked by from __future__ import annotations (the module imports fine, but it would break under get_type_hints() or if the future-import were removed). Fixed: added from typing import Optional.
  • tests/validation/test_validator.py — a _ScriptedRunner was built then overridden by _PerTaskRunner and never used (F841): dead test setup. Removed.

Changes

  • pyproject.toml[tool.ruff.lint] select = ["E4","E7","E9","F"] (ruff's default set, no E501, no formatter); per-file-ignores "tests/**" = ["E402","E702","E741"] (tests may use compact import/statement style; all pyflakes F rules stay enforced in tests). ruff>=0.15,<0.16 pinned in the dev group.
  • .pre-commit-config.yamlruff hook (--fix), pinned v0.15.20; ruff-format explicitly omitted.
  • .github/workflows/tests.yml — a lint job running uv run ruff check evolution tests.
  • Cleanups so shipped code (evolution/) is fully clean under the rules: autofixed 65 unused imports + 20 empty f-strings; preserved core/__init__.py re-exports via __all__; moved evolve_skill.py's basicConfig() below the import block (E402, no behavioral change); split semicolon statements in audit_gaming.py (E702).
  • docs/upstream_pr_triage.md — recorded the adoption (review log + refreshed the fix(closed-loop): deliver the candidate skill when a task omits skills_src #106 row).

Verification

  • ruff check evolution tests → clean (exit 0).
  • Full non-slow suite green: 1754 passed.
  • All 17 modified shipped modules import cleanly.
  • Independent code-review pass: no findings.

Follow-up for the maintainer (not in this PR)

The lint CI job runs but isn't a required status check — making it required (and thus gating --auto merges) is a one-line branch-protection change. ruff-format + gitleaks (#107) remain deferred.

Measured first: ruff's default rule set (E4/E7/E9/F) flagged 134 issues
(79 auto-fixable). Adopt the linter only — [tool.ruff.lint] in pyproject
(select E4/E7/E9/F, no E501), ruff pinned in the dev group, a ruff
pre-commit hook (--fix), and a `lint` CI job. The formatter stays deferred:
169/225 files would reflow and the tree is written to ~100 chars, so a
one-shot line-length-100 reformat (logged in .git-blame-ignore-revs) is a
separate, optional path.

Shipped code (evolution/) is fully clean under the rules; tests/** gets a
scoped ignore for three style-only rules (E402/E702/E741) while every
pyflakes (F) real-bug rule stays enforced there.

The linter surfaced two genuine latent issues, fixed here:
- tool_module.py: undefined `Optional` (F821), masked by
  `from __future__ import annotations`.
- test_validator.py: dead `_ScriptedRunner` setup overridden by
  `_PerTaskRunner` (F841).

Mechanically: autofixed 65 unused imports + 20 empty f-strings; preserved
the core/__init__ re-exports via __all__; moved evolve_skill's basicConfig
below the import block (E402); split semicolon statements in audit_gaming
(E702).

Verified: ruff check clean, full non-slow suite green (1754 passed), all
modified shipped modules import cleanly. Recorded the adoption in
docs/upstream_pr_triage.md (the #106 deferred follow-up).
@jramos
jramos enabled auto-merge (squash) June 29, 2026 04:23
@jramos
jramos merged commit bee6388 into main Jun 29, 2026
5 checks passed
@jramos
jramos deleted the chore/ruff-check-adoption branch June 29, 2026 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant