Repository navigation
Use rule name and code in formatter incompatibility warnings - #28571
Merged
MichaReiser merged 2 commits intoSep 16, 2026
Merged
Conversation
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
Contributor
Author
|
@MichaReiser can you review it? |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
warn_incompatible_formatter_settings(incrates/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 (forMissingTrailingComma/IncorrectBlankLineBeforeClass), which already usedRule::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 existingRule::name_and_code()helper, matching the format already used elsewhere in the same function.Fixes #28551
Test Plan
Updated the existing
conflicting_optionsandconflicting_options_stdininline snapshot tests incrates/ruff/tests/cli/format.rs, which exercise this exact function, and regenerated them withcargo insta accept. Also manually ranruff format --checkagainst configs that trigger each of the affected warnings to confirm the new output shows both the rule name and code.