Skip to content

[ruff] Expand lint.external docs and add sub-diagnostic (RUF100, RUF102)#23268

Merged
ntBre merged 10 commits intomainfrom
brent/ruf102-docs
Feb 18, 2026
Merged

[ruff] Expand lint.external docs and add sub-diagnostic (RUF100, RUF102)#23268
ntBre merged 10 commits intomainfrom
brent/ruf102-docs

Conversation

@ntBre
Copy link
Contributor

@ntBre ntBre commented Feb 13, 2026

Summary

We've gotten a couple of recent reports about suppressing both of these
rules (#23191 and #23267 at least), so I think it's worth trying to provide more
information in the diagnostics and also in the documentation. The connection to
lint.external was at least documented, but the rule docs themselves didn't
really help unless you clicked through to the setting itself.

I'm not 100% sold on this sub-diagnostic message. It feels a bit verbose, but I
like that it's explicit. Given full control over the placement, I'd probably put
it below the fix diff, but this seems like the best option we currently have
available.

Test Plan

Updated snapshot tests

…, `RUF102`)

Summary
--

We've gotten a couple of recent reports about suppressing both of these
rules (#23191 and #23267 at least), so I think it's worth trying to provide more
information in the diagnostics and also in the documentation. The connection to
`lint.external` was at least documented, but the rule docs themselves didn't
really help unless you clicked through to the setting itself.

I'm not 100% sold on this sub-diagnostic message. It feels a bit verbose, but I
like that it's explicit. Given full control over the placement, I'd probably put
it below the fix diff, but this seems like the best option we currently have
available.

Test Plan
--

Updated snapshot tests
@ntBre ntBre added the documentation Improvements or additions to documentation label Feb 13, 2026
@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 13, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre ntBre requested review from amyreese and dylwil3 February 13, 2026 17:50
Copy link
Member

@amyreese amyreese left a comment

Choose a reason for hiding this comment

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

It looks like this is triggering on regular "unused noqa" instances as well. We probably also need to intentionally do this for RUF102 reported by the range suppression module too.

@amyreese
Copy link
Member

We'll want to add matching logic for range suppressions here:

Something like

if let InvalidRuleCode = kind {
  // add help text here
}

@ntBre ntBre marked this pull request as draft February 13, 2026 18:33
@ntBre
Copy link
Contributor Author

ntBre commented Feb 13, 2026

I don't believe we can match on the violation kind like that, but we can return the DiagnosticGuard and post-process at the call site at least.

@ntBre ntBre marked this pull request as ready for review February 13, 2026 19:02
Copy link
Collaborator

@dylwil3 dylwil3 left a comment

Choose a reason for hiding this comment

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

Nice!

@ntBre
Copy link
Contributor Author

ntBre commented Feb 18, 2026

There's no way that this is the right way to format this code:

+        let process_pending_diagnostics = |key: Option<TextRange>,
+                                           grouped_diagnostic: &Option<(
+            TextRange,
+            SuppressionDiagnostic,
+        )>|
+         -> bool {

https://github.com/astral-sh/ruff/actions/runs/22161202610/job/64078091120?pr=23268

I think I'll extract this closure into a function to avoid this, sorry for the big diff! Somehow rustfmt got really unhappy after the merge.

@ntBre ntBre merged commit 5f4eb2c into main Feb 18, 2026
42 checks passed
@ntBre ntBre deleted the brent/ruf102-docs branch February 18, 2026 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants