From a6d269f263945dcb5a82d2e643c4c62ee592983f Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 7 Jun 2023 18:33:40 -0400 Subject: [PATCH] Apply `dict.get` fix before ternary rewrite (#4944) --- crates/ruff/src/autofix/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/ruff/src/autofix/mod.rs b/crates/ruff/src/autofix/mod.rs index 2bc6e1b12b662..df4fe0e69cbe1 100644 --- a/crates/ruff/src/autofix/mod.rs +++ b/crates/ruff/src/autofix/mod.rs @@ -110,6 +110,13 @@ fn cmp_fix(rule1: Rule, rule2: Rule, fix1: &Fix, fix2: &Fix) -> std::cmp::Orderi // Apply `EndsInPeriod` fixes before `NewLineAfterLastParagraph` fixes. (Rule::EndsInPeriod, Rule::NewLineAfterLastParagraph) => std::cmp::Ordering::Less, (Rule::NewLineAfterLastParagraph, Rule::EndsInPeriod) => std::cmp::Ordering::Greater, + // Apply `IfElseBlockInsteadOfDictGet` fixes before `IfElseBlockInsteadOfIfExp` fixes. + (Rule::IfElseBlockInsteadOfDictGet, Rule::IfElseBlockInsteadOfIfExp) => { + std::cmp::Ordering::Less + } + (Rule::IfElseBlockInsteadOfIfExp, Rule::IfElseBlockInsteadOfDictGet) => { + std::cmp::Ordering::Greater + } _ => std::cmp::Ordering::Equal, }) }