ci: enable ruff preview rules under the budgeted strict gate - #30352
Closed
mateo-berri wants to merge 1 commit into
Closed
ci: enable ruff preview rules under the budgeted strict gate#30352mateo-berri wants to merge 1 commit into
mateo-berri wants to merge 1 commit into
Conversation
Turn on ruff preview in the strict-budget lane (ruff-strict.toml) only, leaving the clean gate (ruff.toml) untouched so make lint-ruff stays at zero. Enumerate the 118 firing codes explicitly with explicit-preview-rules so the gate is deterministic and stable across ruff upgrades rather than depending on preview auto-selecting the broad catalog. Grandfather the existing 58438 violations into ruff-strict-budget.json as per-rule baselines with headroom, so only net-new violations fail CI. The existing ten rules keep their hand-tuned slack; the new rules get slack 10 when the baseline is 50 or more and 3 otherwise.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
Author
|
Superseded by #30379, which keeps this ruff-preview change and adds the ANN return-type rules plus the mypy and basedpyright baseline gates on a Generated by Claude Code |
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.
Relevant issues
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
make test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewCI (LiteLLM team)
Link:
Link:
Links:
Screenshots / Proof of Fix
The gate is deterministic, so the proof is the gate itself, run two ways. First, the codebase as-is passes the new ceiling:
The clean gate is untouched and still at zero, so
make lint-ruffis unaffected:And the ratchet update is idempotent against the committed baselines (no diff), confirming the budget matches the current tree:
To see it actually catch a regression, add a single new banned-
Anyor aUP006-style legacy annotation on a fresh line, rerunpython scripts/ruff_strict_gate.py, and the gate fails pointing at the new line.Type
🚄 Infrastructure
Changes
This turns on ruff's preview rule set, but only in the budgeted strict lane, never in the clean gate.
Ruff has two lanes here:
ruff.tomldrivesmake lint-ruff(ruff check .) which must stay at zero, andruff-strict.tomldrivesscripts/ruff_strict_gate.py, which counts violations against abaseline + slackceiling inruff-strict-budget.json. Preview belongs in the second lane because that is the only one with a grandfathering mechanism; flipping preview on in the clean gate would surface ~48k violations with no way to absorb them.Enabling
preview = truewith non-explicit selection makes ruff pull in its broad preview catalog (415 rules enabled on this tree), which is both noisy and liable to shift on every ruff upgrade. Instead the config setsexplicit-preview-rules = trueand enumerates the exact 118 codes that fire today, so the gate is deterministic and a ruff bump never silently adds or drops a gated rule.The 58438 existing violations across those 118 rules are grandfathered into
ruff-strict-budget.jsonas per-rule baselines. The original ten rules keep their hand-tuned slack; each newly tracked rule gets slack 10 when its baseline is 50 or more and 3 otherwise, so there is a little headroom for churn while net-new violations still fail CI. Two pre-existing rules drifted up by one (ANN4011885 -> 1886,TID2512404 -> 2405) and are re-captured at their current counts.No script or Makefile changes were needed;
ruff_strict_gate.pyalready reads the rule set fromruff-strict.tomland the budget from the JSON, somake lint-strict-budgetandmake lint-strict-budget-updatepick this up as-is.Generated by Claude Code