chore: adopt ruff linter (check-only) + fix two latent bugs it surfaced - #148
Merged
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adopts ruff as a linter (check-only; the formatter stays deferred) — the
rufffollow-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)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
E501is intentionally not selected, and a one-shotline-length = 100reformat (recorded in.git-blame-ignore-revs) remains the separate, optional path.Two genuine latent bugs the linter caught
evolution/tools/tool_module.py—Optionalused in an annotation but never imported (F821), masked byfrom __future__ import annotations(the module imports fine, but it would break underget_type_hints()or if the future-import were removed). Fixed: addedfrom typing import Optional.tests/validation/test_validator.py— a_ScriptedRunnerwas built then overridden by_PerTaskRunnerand never used (F841): dead test setup. Removed.Changes
pyproject.toml—[tool.ruff.lint] select = ["E4","E7","E9","F"](ruff's default set, noE501, 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.16pinned in the dev group..pre-commit-config.yaml—ruffhook (--fix), pinnedv0.15.20;ruff-formatexplicitly omitted..github/workflows/tests.yml— alintjob runninguv run ruff check evolution tests.evolution/) is fully clean under the rules: autofixed 65 unused imports + 20 empty f-strings; preservedcore/__init__.pyre-exports via__all__; movedevolve_skill.py'sbasicConfig()below the import block (E402, no behavioral change); split semicolon statements inaudit_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).Follow-up for the maintainer (not in this PR)
The
lintCI job runs but isn't a required status check — making it required (and thus gating--automerges) is a one-line branch-protection change.ruff-format+ gitleaks (#107) remain deferred.