Skip to content

chore(lint): widen ANN slack to 10% of baseline and drop PLR0913 from the strict gate - #31335

Merged
mateo-berri merged 4 commits into
litellm_internal_stagingfrom
litellm_ann-plr0913-10pct-slack-4a6d
Jun 25, 2026
Merged

chore(lint): widen ANN slack to 10% of baseline and drop PLR0913 from the strict gate#31335
mateo-berri merged 4 commits into
litellm_internal_stagingfrom
litellm_ann-plr0913-10pct-slack-4a6d

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Relevant issues

Loosens the strict ruff gate so it stops blocking PRs that merely touch shared, dynamically-typed plumbing in passthrough/proxy code, and hardens the non-gating ratchet guard so the loosening is fully visible. Context is the GigaChat passthrough PR #25886, which was sitting 2 over both the ANN401 and PLR0913 caps even though the violations are inherent to httpx pass-through signatures and Python's generator protocol

Linear ticket

N/A

Type

🚄 Infrastructure

Changes

The strict ruff gate (scripts/ruff_strict_gate.py) computes each rule's ceiling as baseline + slack and is already grandfathered, so it only blames a change for net-new violations that push the whole-repo total past that ceiling. Three adjustments here

First, the slack for the high-volume ANN rules is bumped to 10% of baseline (rounded half up). "High-volume" is the set of ANN rules with a baseline at or above 500, which is also exactly the set that already carried slack of 20 or more; the smaller ANN rules (ANN002 at 64, ANN205 at 117, ANN206 at 120) are intentionally left untouched. Baselines are unchanged, so the ratchet still tightens normally via make lint-budget-update; only the headroom grows

rule baseline old slack new slack (10%) new cap
ANN001 2865 50 287 3152
ANN003 759 30 76 835
ANN201 1944 50 194 2138
ANN202 858 30 86 944
ANN204 658 20 66 724
ANN401 1886 50 189 2075

Second, PLR0913 (too-many-arguments) is removed from the strict gate entirely, both its budget entry and its slot in the ruff-strict.toml select list. It is a broad rule that trips a large share of PRs, so the plan is to roll these rules out gradually rather than enforce everything at once. It can be re-added later once the codebase is in better shape. There are no existing # noqa: PLR0913 suppressions, so removing it from select does not create any unused-noqa (RUF100) failures

Third, the non-gating ratchet guard (scripts/budget_ratchet_check.py) is hardened. It already flagged a raised ceiling, a dropped rule, and a deleted budget file, but a baseline increase that was masked by an equal slack cut (ceiling held flat) slipped through; in fact the old tests explicitly blessed that case. Since baseline is itself meant to be a one-way downward ratchet (the docstring's own banned-API example is a baseline that should turn the check red), the guard now also fails when a rule's baseline rises on its own, and reports both reasons when a ceiling and a baseline rise together. Rule-removal and file-deletion detection are unchanged

Worth noting for contributors: these violations can already be suppressed inline with # noqa: <CODE> <reason>, which drops them out of the gate's count. ruff honors the suppression and does not flag it as an unused noqa, so a justified noqa is a valid escape hatch for the genuinely unavoidable cases (for example the send/throw generator-protocol Anys). A bare # noqa without codes or a reason is itself caught by the custom LIT003 check, so the reason is not optional

Screenshots / Proof of Fix

Strict gate passes on this branch:

$ python3 scripts/ruff_strict_gate.py --base origin/litellm_internal_staging
OK: every strict rule is within its codebase ceiling (base origin/litellm_internal_staging)

Ratchet guard now catches a baseline bump that keeps the ceiling flat (unit tests, 13 passing):

$ python3 -m pytest tests/test_litellm/test_budget_ratchet_check.py -q
13 passed
# new: test_raised_baseline_is_a_regression_even_when_ceiling_held_flat
#      test_raised_baseline_and_ceiling_report_both_reasons

The widened ANN401 cap clears the total that PR #25886 currently breaches (1938 < 2075), and PLR0913 is no longer gated at all. The budget-ratchet job is expected to be red on this PR by design (it is non-gating and exists precisely to make this loosening obvious in review)

Slack Thread

Open in Web Open in Cursor 

…me ANN rules and PLR0913

Co-authored-by: Mateo Wang <mateo-berri@users.noreply.github.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Co-authored-by: Mateo Wang <mateo-berri@users.noreply.github.com>
@cursor cursor Bot changed the title chore(lint): widen ruff budget slack to 10% of baseline for high-volume ANN rules and PLR0913 chore(lint): widen ANN slack to 10% of baseline and drop PLR0913 from the strict gate Jun 25, 2026
@mateo-berri
mateo-berri marked this pull request as ready for review June 25, 2026 19:55
@greptile-apps

greptile-apps Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR loosens the strict ruff gate's ANN-rule headroom to 10% of baseline, drops PLR0913 from the gate entirely, and compensates by hardening the non-gating ratchet guard to also catch baseline increases masked by a simultaneous slack cut.

  • ruff-strict-budget.json / ruff-strict.toml: Slack for the six high-volume ANN rules (baseline ≥ 500) grows to 10% of each baseline; PLR0913 is fully removed from both the budget and the select list.
  • scripts/budget_ratchet_check.py: New _baselines() helper and _regression_detail() function detect a raised baseline even when slack is cut to hold the ceiling flat; both reasons are reported together when both apply.
  • tests/test_litellm/test_budget_ratchet_check.py: Two new tests cover the baseline-only and baseline+ceiling regression paths; the previously-blessed "swap slack for baseline at same ceiling" case is reclassified as a regression and receives its own dedicated test.

Confidence Score: 5/5

Safe to merge — changes are confined to lint infrastructure scripts, budget config, and their unit tests, with no production code affected.

The change is a well-scoped lint-gate adjustment: widening headroom for annotation rules to unblock passthrough code, removing a broadly-tripping argument-count rule, and simultaneously strengthening the ratchet guard so the loosening is permanently visible. All three changes are explained, the new behavior is covered by 13 passing unit tests, and no production logic is touched.

No files require special attention.

Important Files Changed

Filename Overview
ruff-strict-budget.json Widens ANN rule slacks to 10% of baseline for high-volume rules (≥500 violations) and removes the PLR0913 entry entirely; baselines are unchanged.
ruff-strict.toml Removes PLR0913 from the strict select list; all other rules are unchanged.
scripts/budget_ratchet_check.py Hardens the non-gating ratchet guard to flag baseline increases even when slack is cut to keep the ceiling flat; adds _baselines() helper and _regression_detail() with dual-reason reporting.
tests/test_litellm/test_budget_ratchet_check.py Adds two new tests for the baseline-increase detection; the previously-blessed "slack traded for baseline" case is correctly reclassified as a regression and moved to its own dedicated test.

Reviews (2): Last reviewed commit: "fix(lint): ratchet-guard rising baseline..." | Re-trigger Greptile

cursoragent and others added 2 commits June 25, 2026 20:04
…itellm_ann-plr0913-10pct-slack-4a6d

Co-authored-by: Mateo Wang <mateo-berri@users.noreply.github.com>
…ask them

Co-authored-by: Mateo Wang <mateo-berri@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 2108850. Configure here.

@mateo-berri
mateo-berri merged commit 92d0788 into litellm_internal_staging Jun 25, 2026
125 of 127 checks passed
@mateo-berri
mateo-berri deleted the litellm_ann-plr0913-10pct-slack-4a6d branch June 25, 2026 21:43
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.

4 participants