Skip to content

[ruff] Ignore "unknown" rule codes in RUF100 when RUF102 is enabled#23531

Merged
amyreese merged 7 commits intomainfrom
amy/ruf100-102-overlap
Feb 25, 2026
Merged

[ruff] Ignore "unknown" rule codes in RUF100 when RUF102 is enabled#23531
amyreese merged 7 commits intomainfrom
amy/ruf100-102-overlap

Conversation

@amyreese
Copy link
Member

@amyreese amyreese commented Feb 24, 2026

Previously, any #noqa with an unknown/invalid rule code (eg,
from a flake8 plugin we don't support) would generate both a RUF100
(unused noqa) diagnostic as well as RUF102 (invalid rule code).
When both rules are enabled, this would create an "overlap" between
the two rules, resulting in duplicate diagnostics as well as confusing
behavior when dealing with fixes from one or the other.

This modifies the RUF100 rule to ignore unknown codes, and only
report diagnostics for known codes that are unused.

Issue #23456

@amyreese amyreese added the rule Implementing or modifying a lint rule label Feb 24, 2026
@amyreese amyreese requested a review from ntBre February 24, 2026 01:38
@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 24, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@amyreese amyreese added the suppression Related to supression of violations e.g. noqa label Feb 24, 2026
@amyreese amyreese changed the title Ignore "unknown" rule codes in RUF100 when RUF102 enabled [ruff] Ignore "unknown" rule codes in RUF100 when RUF102 is enabled Feb 24, 2026
@amyreese amyreese requested a review from ntBre February 25, 2026 22:57
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

We might want to add a ## See also section to both rules pointing to the other one, but this otherwise makes sense to me. Example from UP046: https://docs.astral.sh/ruff/rules/non-pep695-generic-class/#see-also

@amyreese amyreese force-pushed the amy/ruf100-102-overlap branch from 59ca2f2 to 1ae50a7 Compare February 25, 2026 23:22
@amyreese amyreese merged commit db48804 into main Feb 25, 2026
42 checks passed
@amyreese amyreese deleted the amy/ruf100-102-overlap branch February 25, 2026 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rule Implementing or modifying a lint rule suppression Related to supression of violations e.g. noqa

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants