Repository navigation
Adopt ruff for linting and formatting, replacing flake8 (#469) - #470
Merged
Merged
Conversation
Replaces flake8 (which was only ever running a minimal E9/F63/F7/F82 syntax floor check, never real linting -- see .flake8's own extend-ignore list) with ruff, using the same baseline-gated CI pattern established for mypy (#430) and dead_key_audit.py (#325): tests/ruff_audit.py + ruff_audit_baseline.json, wired into a new .github/workflows/ruff-audit.yml. RULE SELECTION (pyproject.toml [tool.ruff.lint]) Deliberately scoped, not `ALL` -- measured actual hit counts against this codebase before deciding what to include: - Included: E/W (pycodestyle), F (pyflakes), B (bugbear), C4 (comprehensions), SIM (simplify), I (isort), ARG (unused args), UP (pyupgrade, target-version py39), S (bandit security -- this project IS a security scanner, so dogfooding it on its own code has obvious value, and it was only 47 hits, not noisy), PERF, DTZ (naive datetime), A (builtins), RSE (raise), RUF (ruff-specific). - Excluded after measuring: BLE/TRY (80+53 hits, but sampling showed they're almost entirely flagging this codebase's *deliberate* `except Exception:` fault-isolation pattern -- documented "DEFENSIVE ARCHITECTURE" design throughout, not bugs) -- enabling them would've buried real signal under intentional-design noise. D (528, docstring-style enforcement against a prose-docstring convention that matches no standard style). T20 (411, this is a CLI-heavy toolkit -- most print() calls are legitimate user-facing output). G (242, f-string-vs-%-style logging is genuinely mixed by design already, not clearly wrong). ANN (redundant with the mypy epic just completed). E501 (line-too-long) was ALSO explicitly ignored in the old .flake8 config already, and at 464 of the initial 705 raw findings would have been ~66% of the baseline on its own, drowning out the other 27 rule families' genuinely diverse findings. ONE-TIME REPO CLEANUP (before baselining, so it doesn't rot forever) - `ruff check --fix`: 500 safe autofixes (import sorting, trailing whitespace, redundant open() modes, etc). - `ruff check --select=UP006,UP035 --fix --unsafe-fixes`: 581 PEP 585 typing modernizations (Dict/List/Set/Tuple -> dict/list/set/tuple). Marked "unsafe" by ruff's own conservatism, but confirmed safe here: this project requires Python >=3.9 (PEP 585 generics work natively at runtime from 3.9 on), and a full `mypy` re-run afterward is still clean (Success: no issues found in 65 source files). - `ruff format`: 29 files reformatted to a consistent style (replaces the vestigial [tool.black] config, which was configured but never actually wired into anything). - Full 866-test pytest suite re-run clean after all of the above -- no behavioral changes, only mechanical ones. Baseline after cleanup: 241 findings / 240 unique keys across 27 rule families, none dominant (largest is SIM102 at 17). CI CHANGES - New ruff-audit.yml: baseline-gated lint (240-key baseline) + zero-tolerance `ruff format --check` (zero-tolerance because the whole repo was just reformatted, so there's no backlog to carry -- letting it drift would just mean redoing this same cleanup later). Ruff's version is pinned here (unlike mypy-audit.yml's unpinned `pip install mypy`) because ruff ships new lint rules far more frequently than mypy does; an unpinned version could silently add baseline findings on a PR that touched no lint-relevant code. - smoke-test.yml: flake8's syntax-floor step replaced with the ruff equivalent (same F63/F7/F82 codes -- ruff kept pyflakes' numbering), still running across the full OS/Python-version matrix as a cross-platform floor check, distinct in purpose from ruff-audit.yml's single-environment broader lint. - gitgalaxy/requirements.txt: flake8 and its now-orphaned transitive deps (mccabe, pycodestyle, pyflakes) removed, ruff added.
Comment on lines
+18
to
+21
| from gitgalaxy.standards.language_standards import ( | ||
| LANGUAGE_DEFINITIONS, # noqa: F401 | ||
| LENS_CONFIG, | ||
| ) |
Contributor
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.
Summary
Replaces flake8 (which only ever ran a minimal
E9/F63/F7/F82syntax-floor check in CI, never real linting) with ruff, using the same baseline-gated pattern established for mypy (#430) anddead_key_audit.py(#325).Rule selection (measured actual hit counts against this codebase before deciding, not guessed):
E/W,F,B,C4,SIM,I,ARG,UP(target-version py39),S(bandit security -- this project IS a security scanner, dogfooding value is obvious, and only 47 hits),PERF,DTZ,A,RSE,RUF.BLE/TRY(80+53 hits, almost entirely flagging this codebase's deliberateexcept Exception:fault-isolation pattern, not bugs),D(528, docstring style doesn't match any standard convention),T20(411, this is a CLI-heavy toolkit -- mostprint()calls are legitimate output),G(242, f-string-vs-%-style logging is genuinely mixed by design),ANN(redundant with the mypy epic).E501was also excluded -- already ignored in the old.flake8config, and at 464/705 raw findings would've been ~66% of the baseline alone.One-time cleanup before baselining (so the backlog doesn't start already rotten):
ruff check --fix: 500 safe autofixes.ruff check --select=UP006,UP035 --fix --unsafe-fixes: 581 PEP 585 typing modernizations (Dict/List/etc ->dict/list/etc). Marked "unsafe" by ruff's own conservatism, confirmed safe here (project requires Python >=3.9; fullmypyre-run afterward is still clean).ruff format: 29 files reformatted (replaces the vestigial[tool.black]config that was never actually wired into anything).Baseline after cleanup: 241 findings / 240 unique keys across 27 rule families, none dominant (largest is
SIM102at 17).CI changes:
ruff-audit.yml: baseline-gated lint + zero-toleranceruff format --check(zero-tolerance since there's no backlog to carry after the repo-wide reformat). Ruff's version is pinned (unlike mypy-audit.yml's unpinned mypy) since ruff ships new rules much more frequently -- an unpinned version could silently add findings on an unrelated PR.smoke-test.yml: flake8's syntax-floor step replaced with the ruff equivalent (F63/F7/F82, same pyflakes numbering), still running across the full OS/Python-version matrix.gitgalaxy/requirements.txt: flake8 + orphaned transitive deps (mccabe, pycodestyle, pyflakes) removed, ruff added.Epic: #469
Test plan
mypy gitgalaxy/ --ignore-missing-imports: stillSuccess: no issues found in 65 source filesafter the mass typing modernizationpython tests/mypy_audit.py --ci: passespython tests/dead_key_audit.py --ci: no new findingspython tests/ruff_audit.py --ci: passes against the new 240-key baseline.pyfiles undergitgalaxy/still parse (ast.parsesweep)pytest tests/ -q: 866 passed, 1 deselected, 1 xfailed -- identical to pre-change🤖 Generated with Claude Code