Skip to content

Allow human-readable names in suppression comments#25614

Draft
ntBre wants to merge 4 commits into
mainfrom
brent/human-readable-suppressions
Draft

Allow human-readable names in suppression comments#25614
ntBre wants to merge 4 commits into
mainfrom
brent/human-readable-suppressions

Conversation

@ntBre
Copy link
Copy Markdown
Contributor

@ntBre ntBre commented Jun 3, 2026

Summary

I decided to start trying to break up #23701, and this looked like the easiest first piece. This PR allows using human-readable rule names in the new ruff:ignore and similar suppression comments, in preview.

Rule names are still disallowed in noqa comments, and rule codes are still allowed in ruff:ignore comments.

I did notice one surprising property here in that a noqa comment with a rule name does not emit invalid-rule-code (RUF102), even on main. This seems to be an artifact of our noqa parsing:

// Reset start of token so it does not include whitespace
self.cursor.start_token();
match self.cursor.bump() {
// Ex) # noqa: F401
// ^
Some(c) if c.is_ascii_uppercase() => {
self.cursor.eat_while(|chr| chr.is_ascii_uppercase());
if !self.cursor.eat_if(|c| c.is_ascii_digit()) {

that we may also want to consider updating now.

Test Plan

New mdtests

@ntBre ntBre added suppression Related to supression of violations e.g. noqa preview Related to preview mode features labels Jun 3, 2026
settings.preview.is_enabled()
}

// https://github.com/astral-sh/ruff/pull/TODO
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
// https://github.com/astral-sh/ruff/pull/TODO
// https://github.com/astral-sh/ruff/pull/25614

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Jun 3, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

ntBre added a commit that referenced this pull request Jun 5, 2026
Summary
--

From what I can tell, there's not really an easy way to preview-gate this. I don't think we have
access to configuration in this subcommand, and it doesn't seem easy to pass it to clap even if we
had it. However, I don't think there's much downside to being more permissive here and allowing this
even before other human-readable names work.

This is currently stacked on #25614, but it just needs the `FromStr` derived by the strum macro.

Test Plan
--

New CLI test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Related to preview mode features suppression Related to supression of violations e.g. noqa

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant