Skip to content

Chore: Pin ruff rule selection - #134

Merged
askb merged 1 commit into
lfreleng-actions:mainfrom
modeseven-lfreleng-actions:chore/pin-ruff-rule-selection
Jul 30, 2026
Merged

Chore: Pin ruff rule selection#134
askb merged 1 commit into
lfreleng-actions:mainfrom
modeseven-lfreleng-actions:chore/pin-ruff-rule-selection

Conversation

@ModeSevenIndustrialSolutions

@ModeSevenIndustrialSolutions ModeSevenIndustrialSolutions commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Why

This repo runs the ruff hook with no ruff configuration, so it applies whatever ruff's default rule set happens to be. That default is not stable across releases — verified directly:

$ ruff 0.15.22 check --show-settings --isolated
 59 rules across  2 categories (E, F)

$ ruff 0.16.0 check --show-settings --isolated
413 rules across 38 categories

A 7× expansion in a patch-level bump. The routine autoupdate that crossed it broke 15 repos in this org simultaneously on untouched code — including this one, where #133 is blocked on 6 violations.

What

[lint]
select = ["E", "W", "F", "I", "B", "C4", "UP"]
ignore = ["E501", "B008"]

Not invented — this is the de facto house style, a superset in 13 of the 16 org repos that already pin their rules.

A standalone .ruff.toml because this repo has no pyproject.toml.

Selecting these categories switches every other rule off — that is the point. Adopting them becomes a deliberate, reviewed change rather than a side effect of a version bump.

line-length and target-version are left unset on purpose — both would change behaviour rather than pin it (target-version alters which pyupgrade rules fire). Standardising those is separate work.

Effect on #133

All 6 blocking violations fall outside the pinned set and cease to exist:

Rule Count In core-7?
EXE001 2 No — EXE not selected
BLE001 1 No — BLE not selected
PIE810 1 No — PIE not selected
SIM103 1 No — SIM not selected
SIM115 1 No — SIM not selected

Two of those (BLE001 on a tomllib.load wrapper, SIM115 on the conditional emit() file handle) were the ones needing a judgement call, where the existing code is not actually wrong. This removes the need to contort them.

Validation

  • No code changes needed — verified clean under the pinned set with ruff 0.16.0 against the files the hook selects
  • ruff check --show-settings confirms enabled categories drop from 38 to B C E F I UP W
  • pre-commit run --all-files → all hooks pass

@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions requested review from a team and Copilot July 28, 2026 14:09
@github-actions github-actions Bot added the chore Code chores (dependency updates, etc) label Jul 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds an explicit Ruff configuration to stabilize the lint rule set across Ruff releases, avoiding unexpected rule expansions from ruff default selections when pre-commit autoupdates change the Ruff version.

Changes:

  • Introduces a standalone .ruff.toml with an explicit [lint] select list (E/W/F/I/B/C4/UP) and a small global ignore set (E501, B008).
  • Adds tests/**/*.py per-file ignores to prevent future widening of select from immediately flagging test modules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

tykeal
tykeal previously approved these changes Jul 28, 2026

@tykeal tykeal 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.

🤖 Dependamerge
Approved this pull request ✅

Copilot AI review requested due to automatic review settings July 28, 2026 16:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

.ruff.toml:17

  • The sentence "Pinning does not decline the unselected rules" reads like a typo/word-choice error and is unclear about the intent (pinning is about controlling which rules run by default, not “declining” rules). Consider rephrasing to make the point explicit.
# Pinning does not decline the unselected rules.  It makes adopting them
# a deliberate, reviewed change instead of a side effect of a version

This repository runs the ruff hook with no ruff configuration, so it
applies whatever ruff's *default* rule set happens to be.  That default
is not stable across releases:

    ruff 0.15.22 ->  59 rules across  2 categories (E, F)
    ruff 0.16.0  -> 413 rules across 38 categories

A routine pre-commit autoupdate crossing that boundary changed which
rules run and broke fifteen repositories in this organisation at once,
on code nobody had touched.  Ninety-six repositories carry the hook
with no configuration, so all of them are exposed to the next bump.

Pin the rule set to the de-facto house style, which appears as a
superset in 13 of the 16 repositories that already pin their own.  This
does not decline the unselected rules; it makes adopting them a
deliberate, reviewed change rather than a side effect of a version bump.

line-length and target-version are left unset on purpose.  Both alter
existing behaviour -- target-version changes which pyupgrade rules fire
-- and the aim here is to fix which rules run, nothing else.

No code changes accompany this: the tree is already clean under the
pinned rule set, verified with ruff 0.16.0 against the files the hook
currently selects.

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
@askb
askb merged commit 4b54435 into lfreleng-actions:main Jul 30, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Code chores (dependency updates, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants