Skip to content

Use rule name and code in formatter incompatibility warnings - #28571

Merged
MichaReiser merged 2 commits into
astral-sh:mainfrom
Aniket-a14:fix-formatter-warning-rule-names
Sep 16, 2026
Merged

MichaReiser merged 2 commits into
astral-sh:mainfrom
Aniket-a14:fix-formatter-warning-rule-names

Conversation

@Aniket-a14

Copy link
Copy Markdown
Contributor

Summary

warn_incompatible_formatter_settings (in crates/ruff/src/commands/format.rs) prints several warnings about formatter/linter option conflicts, but a handful of them referenced the conflicting rule only by its bare code (e.g. `Q000`, `W191`, `D206`), instead of the rule's name and code together. This meant the message named the rule inconsistently compared to a nearby warning in the same function (for MissingTrailingComma/IncorrectBlankLineBeforeClass), which already used Rule::name_and_code() to print e.g. `unused-import` (`F401`).

This fixes the 8 messages that hard-coded a bare rule code (W191, D206, E111, E114, Q000, Q003, Q001, Q002, ISC001) to instead use the existing Rule::name_and_code() helper, matching the format already used elsewhere in the same function.

Fixes #28551

Test Plan

Updated the existing conflicting_options and conflicting_options_stdin inline snapshot tests in crates/ruff/tests/cli/format.rs, which exercise this exact function, and regenerated them with cargo insta accept. Also manually ran ruff format --check against configs that trigger each of the affected warnings to confirm the new output shows both the rule name and code.

Several `warn_incompatible_formatter_settings` messages printed a bare
rule code (e.g. `Q000`) instead of the rule's name and code, unlike the
similar `MissingTrailingComma`/`IncorrectBlankLineBeforeClass` warning
in the same function. Use the existing `Rule::name_and_code()` helper
for consistency.

Fixes astral-sh#28551
Copilot AI lite review requested due to automatic review settings September 14, 2026 12:43
@astral-sh-bot
astral-sh-bot Bot requested a review from ntBre September 14, 2026 12:43

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Aniket-a14

Copy link
Copy Markdown
Contributor Author

@MichaReiser can you review it?

@MichaReiser MichaReiser added the cli Related to the command-line interface of Ruff or ty label Sep 16, 2026
@astral-sh-bot

astral-sh-bot Bot commented Sep 16, 2026

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

βœ… ecosystem check detected no linter changes.

Linter (preview)

βœ… ecosystem check detected no linter changes.

@MichaReiser
MichaReiser enabled auto-merge (squash) September 16, 2026 08:15
@MichaReiser
MichaReiser merged commit 0af6727 into astral-sh:main Sep 16, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Related to the command-line interface of Ruff or ty

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use rule name with parenthesized rule code in warning messages

3 participants