Skip to content

Commit

Permalink
[formatter] do not emit warnings that the formatter conflicts with …
Browse files Browse the repository at this point in the history
…rule `missing-trailing-commas` if no conflicts
  • Loading branch information
XuehaiPan committed Jan 29, 2025
1 parent 6090408 commit 95e0462
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions crates/ruff/src/commands/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,19 +787,22 @@ pub(super) fn warn_incompatible_formatter_settings(resolver: &Resolver) {
// First, collect all rules that are incompatible regardless of the linter-specific settings.
let mut incompatible_rules = FxHashSet::default();
for setting in resolver.settings() {
for rule in [
for (rule, is_conflicting) in [
// Flags missing trailing commas when all arguments are on its own line:
// ```python
// def args(
// aaaaaaaa, bbbbbbbbb, cccccccccc, ddddddddd, eeeeeeee, ffffff, gggggggggggg, hhhh
// ):
// pass
// ```
Rule::MissingTrailingComma,
(
Rule::MissingTrailingComma, // adds trailing commas
setting.formatter.magic_trailing_comma.is_ignore(), // ignores trailing commas
),
// The formatter always removes blank lines before the docstring.
Rule::IncorrectBlankLineBeforeClass,
(Rule::IncorrectBlankLineBeforeClass, true),
] {
if setting.linter.rules.enabled(rule) {
if is_conflicting && setting.linter.rules.enabled(rule) {
incompatible_rules.insert(rule);
}
}
Expand Down

0 comments on commit 95e0462

Please sign in to comment.