From 8ccbf1ac0354d6585ee8ddc6d3519704e5f1bc5c Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 27 Jun 2024 06:32:13 -0400 Subject: [PATCH] [`flake8-simplify`] Stabilize detection of Yoda conditions for "constant" collections (`SIM300`) (#12050) Co-authored-by: Alex Waygood --- .../src/rules/flake8_simplify/mod.rs | 19 - .../flake8_simplify/rules/yoda_conditions.rs | 46 +-- ...ke8_simplify__tests__SIM300_SIM300.py.snap | 106 +++--- ...ify__tests__preview__SIM300_SIM300.py.snap | 354 ------------------ 4 files changed, 69 insertions(+), 456 deletions(-) delete mode 100644 crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM300_SIM300.py.snap diff --git a/crates/ruff_linter/src/rules/flake8_simplify/mod.rs b/crates/ruff_linter/src/rules/flake8_simplify/mod.rs index e68c9d6b471ca..5652d8e40b2c3 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/mod.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/mod.rs @@ -9,7 +9,6 @@ mod tests { use test_case::test_case; use crate::registry::Rule; - use crate::settings::types::PreviewMode; use crate::test::test_path; use crate::{assert_messages, settings}; @@ -55,22 +54,4 @@ mod tests { assert_messages!(snapshot, diagnostics); Ok(()) } - - #[test_case(Rule::YodaConditions, Path::new("SIM300.py"))] - fn preview_rules(rule_code: Rule, path: &Path) -> Result<()> { - let snapshot = format!( - "preview__{}_{}", - rule_code.noqa_code(), - path.to_string_lossy() - ); - let diagnostics = test_path( - Path::new("flake8_simplify").join(path).as_path(), - &settings::LinterSettings { - preview: PreviewMode::Enabled, - ..settings::LinterSettings::for_rule(rule_code) - }, - )?; - assert_messages!(snapshot, diagnostics); - Ok(()) - } } diff --git a/crates/ruff_linter/src/rules/flake8_simplify/rules/yoda_conditions.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/yoda_conditions.rs index f8f88b1e050e2..a623a7ec36318 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/rules/yoda_conditions.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/rules/yoda_conditions.rs @@ -16,7 +16,6 @@ use crate::cst::helpers::or_space; use crate::cst::matchers::{match_comparison, transform_expression}; use crate::fix::edits::pad; use crate::fix::snippet::SourceCodeSnippet; -use crate::settings::types::PreviewMode; /// ## What it does /// Checks for conditions that position a constant on the left-hand side of the @@ -58,26 +57,15 @@ impl Violation for YodaConditions { #[derive_message_formats] fn message(&self) -> String { - let YodaConditions { suggestion } = self; - if let Some(suggestion) = suggestion - .as_ref() - .and_then(SourceCodeSnippet::full_display) - { - format!("Yoda conditions are discouraged, use `{suggestion}` instead") - } else { - format!("Yoda conditions are discouraged") - } + format!("Yoda condition detected") } fn fix_title(&self) -> Option { let YodaConditions { suggestion } = self; - suggestion.as_ref().map(|suggestion| { - if let Some(suggestion) = suggestion.full_display() { - format!("Replace Yoda condition with `{suggestion}`") - } else { - format!("Replace Yoda condition") - } - }) + suggestion + .as_ref() + .and_then(|suggestion| suggestion.full_display()) + .map(|suggestion| format!("Rewrite as `{suggestion}`")) } } @@ -94,9 +82,9 @@ enum ConstantLikelihood { Definitely = 2, } -impl ConstantLikelihood { +impl From<&Expr> for ConstantLikelihood { /// Determine the [`ConstantLikelihood`] of an expression. - fn from_expression(expr: &Expr, preview: PreviewMode) -> Self { + fn from(expr: &Expr) -> Self { match expr { _ if expr.is_literal_expr() => ConstantLikelihood::Definitely, Expr::Attribute(ast::ExprAttribute { attr, .. }) => { @@ -105,15 +93,15 @@ impl ConstantLikelihood { Expr::Name(ast::ExprName { id, .. }) => ConstantLikelihood::from_identifier(id), Expr::Tuple(ast::ExprTuple { elts, .. }) => elts .iter() - .map(|expr| ConstantLikelihood::from_expression(expr, preview)) + .map(ConstantLikelihood::from) .min() .unwrap_or(ConstantLikelihood::Definitely), - Expr::List(ast::ExprList { elts, .. }) if preview.is_enabled() => elts + Expr::List(ast::ExprList { elts, .. }) => elts .iter() - .map(|expr| ConstantLikelihood::from_expression(expr, preview)) + .map(ConstantLikelihood::from) .min() .unwrap_or(ConstantLikelihood::Definitely), - Expr::Dict(ast::ExprDict { items, .. }) if preview.is_enabled() => { + Expr::Dict(ast::ExprDict { items, .. }) => { if items.is_empty() { ConstantLikelihood::Definitely } else { @@ -121,18 +109,20 @@ impl ConstantLikelihood { } } Expr::BinOp(ast::ExprBinOp { left, right, .. }) => cmp::min( - ConstantLikelihood::from_expression(left, preview), - ConstantLikelihood::from_expression(right, preview), + ConstantLikelihood::from(&**left), + ConstantLikelihood::from(&**right), ), Expr::UnaryOp(ast::ExprUnaryOp { op: UnaryOp::UAdd | UnaryOp::USub | UnaryOp::Invert, operand, range: _, - }) => ConstantLikelihood::from_expression(operand, preview), + }) => ConstantLikelihood::from(&**operand), _ => ConstantLikelihood::Unlikely, } } +} +impl ConstantLikelihood { /// Determine the [`ConstantLikelihood`] of an identifier. fn from_identifier(identifier: &str) -> Self { if str::is_cased_uppercase(identifier) { @@ -230,9 +220,7 @@ pub(crate) fn yoda_conditions( return; } - if ConstantLikelihood::from_expression(left, checker.settings.preview) - <= ConstantLikelihood::from_expression(right, checker.settings.preview) - { + if ConstantLikelihood::from(left) <= ConstantLikelihood::from(right) { return; } diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap index 29c42f6a745ff..8af686ef8545f 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap @@ -1,7 +1,7 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM300.py:2:1: SIM300 [*] Yoda conditions are discouraged, use `compare == "yoda"` instead +SIM300.py:2:1: SIM300 [*] Yoda condition detected | 1 | # Errors 2 | "yoda" == compare # SIM300 @@ -9,7 +9,7 @@ SIM300.py:2:1: SIM300 [*] Yoda conditions are discouraged, use `compare == "yoda 3 | 42 == age # SIM300 4 | ("a", "b") == compare # SIM300 | - = help: Replace Yoda condition with `compare == "yoda"` + = help: Rewrite as `compare == "yoda"` ℹ Safe fix 1 1 | # Errors @@ -19,7 +19,7 @@ SIM300.py:2:1: SIM300 [*] Yoda conditions are discouraged, use `compare == "yoda 4 4 | ("a", "b") == compare # SIM300 5 5 | "yoda" <= compare # SIM300 -SIM300.py:3:1: SIM300 [*] Yoda conditions are discouraged, use `age == 42` instead +SIM300.py:3:1: SIM300 [*] Yoda condition detected | 1 | # Errors 2 | "yoda" == compare # SIM300 @@ -28,7 +28,7 @@ SIM300.py:3:1: SIM300 [*] Yoda conditions are discouraged, use `age == 42` inste 4 | ("a", "b") == compare # SIM300 5 | "yoda" <= compare # SIM300 | - = help: Replace Yoda condition with `age == 42` + = help: Rewrite as `age == 42` ℹ Safe fix 1 1 | # Errors @@ -39,7 +39,7 @@ SIM300.py:3:1: SIM300 [*] Yoda conditions are discouraged, use `age == 42` inste 5 5 | "yoda" <= compare # SIM300 6 6 | "yoda" < compare # SIM300 -SIM300.py:4:1: SIM300 [*] Yoda conditions are discouraged, use `compare == ("a", "b")` instead +SIM300.py:4:1: SIM300 [*] Yoda condition detected | 2 | "yoda" == compare # SIM300 3 | 42 == age # SIM300 @@ -48,7 +48,7 @@ SIM300.py:4:1: SIM300 [*] Yoda conditions are discouraged, use `compare == ("a", 5 | "yoda" <= compare # SIM300 6 | "yoda" < compare # SIM300 | - = help: Replace Yoda condition with `compare == ("a", "b")` + = help: Rewrite as `compare == ("a", "b")` ℹ Safe fix 1 1 | # Errors @@ -60,7 +60,7 @@ SIM300.py:4:1: SIM300 [*] Yoda conditions are discouraged, use `compare == ("a", 6 6 | "yoda" < compare # SIM300 7 7 | 42 > age # SIM300 -SIM300.py:5:1: SIM300 [*] Yoda conditions are discouraged, use `compare >= "yoda"` instead +SIM300.py:5:1: SIM300 [*] Yoda condition detected | 3 | 42 == age # SIM300 4 | ("a", "b") == compare # SIM300 @@ -69,7 +69,7 @@ SIM300.py:5:1: SIM300 [*] Yoda conditions are discouraged, use `compare >= "yoda 6 | "yoda" < compare # SIM300 7 | 42 > age # SIM300 | - = help: Replace Yoda condition with `compare >= "yoda"` + = help: Rewrite as `compare >= "yoda"` ℹ Safe fix 2 2 | "yoda" == compare # SIM300 @@ -81,7 +81,7 @@ SIM300.py:5:1: SIM300 [*] Yoda conditions are discouraged, use `compare >= "yoda 7 7 | 42 > age # SIM300 8 8 | -42 > age # SIM300 -SIM300.py:6:1: SIM300 [*] Yoda conditions are discouraged, use `compare > "yoda"` instead +SIM300.py:6:1: SIM300 [*] Yoda condition detected | 4 | ("a", "b") == compare # SIM300 5 | "yoda" <= compare # SIM300 @@ -90,7 +90,7 @@ SIM300.py:6:1: SIM300 [*] Yoda conditions are discouraged, use `compare > "yoda" 7 | 42 > age # SIM300 8 | -42 > age # SIM300 | - = help: Replace Yoda condition with `compare > "yoda"` + = help: Rewrite as `compare > "yoda"` ℹ Safe fix 3 3 | 42 == age # SIM300 @@ -102,7 +102,7 @@ SIM300.py:6:1: SIM300 [*] Yoda conditions are discouraged, use `compare > "yoda" 8 8 | -42 > age # SIM300 9 9 | +42 > age # SIM300 -SIM300.py:7:1: SIM300 [*] Yoda conditions are discouraged, use `age < 42` instead +SIM300.py:7:1: SIM300 [*] Yoda condition detected | 5 | "yoda" <= compare # SIM300 6 | "yoda" < compare # SIM300 @@ -111,7 +111,7 @@ SIM300.py:7:1: SIM300 [*] Yoda conditions are discouraged, use `age < 42` instea 8 | -42 > age # SIM300 9 | +42 > age # SIM300 | - = help: Replace Yoda condition with `age < 42` + = help: Rewrite as `age < 42` ℹ Safe fix 4 4 | ("a", "b") == compare # SIM300 @@ -123,7 +123,7 @@ SIM300.py:7:1: SIM300 [*] Yoda conditions are discouraged, use `age < 42` instea 9 9 | +42 > age # SIM300 10 10 | YODA == age # SIM300 -SIM300.py:8:1: SIM300 [*] Yoda conditions are discouraged, use `age < -42` instead +SIM300.py:8:1: SIM300 [*] Yoda condition detected | 6 | "yoda" < compare # SIM300 7 | 42 > age # SIM300 @@ -132,7 +132,7 @@ SIM300.py:8:1: SIM300 [*] Yoda conditions are discouraged, use `age < -42` inste 9 | +42 > age # SIM300 10 | YODA == age # SIM300 | - = help: Replace Yoda condition with `age < -42` + = help: Rewrite as `age < -42` ℹ Safe fix 5 5 | "yoda" <= compare # SIM300 @@ -144,7 +144,7 @@ SIM300.py:8:1: SIM300 [*] Yoda conditions are discouraged, use `age < -42` inste 10 10 | YODA == age # SIM300 11 11 | YODA > age # SIM300 -SIM300.py:9:1: SIM300 [*] Yoda conditions are discouraged, use `age < +42` instead +SIM300.py:9:1: SIM300 [*] Yoda condition detected | 7 | 42 > age # SIM300 8 | -42 > age # SIM300 @@ -153,7 +153,7 @@ SIM300.py:9:1: SIM300 [*] Yoda conditions are discouraged, use `age < +42` inste 10 | YODA == age # SIM300 11 | YODA > age # SIM300 | - = help: Replace Yoda condition with `age < +42` + = help: Rewrite as `age < +42` ℹ Safe fix 6 6 | "yoda" < compare # SIM300 @@ -165,7 +165,7 @@ SIM300.py:9:1: SIM300 [*] Yoda conditions are discouraged, use `age < +42` inste 11 11 | YODA > age # SIM300 12 12 | YODA >= age # SIM300 -SIM300.py:10:1: SIM300 [*] Yoda conditions are discouraged, use `age == YODA` instead +SIM300.py:10:1: SIM300 [*] Yoda condition detected | 8 | -42 > age # SIM300 9 | +42 > age # SIM300 @@ -174,7 +174,7 @@ SIM300.py:10:1: SIM300 [*] Yoda conditions are discouraged, use `age == YODA` in 11 | YODA > age # SIM300 12 | YODA >= age # SIM300 | - = help: Replace Yoda condition with `age == YODA` + = help: Rewrite as `age == YODA` ℹ Safe fix 7 7 | 42 > age # SIM300 @@ -186,7 +186,7 @@ SIM300.py:10:1: SIM300 [*] Yoda conditions are discouraged, use `age == YODA` in 12 12 | YODA >= age # SIM300 13 13 | JediOrder.YODA == age # SIM300 -SIM300.py:11:1: SIM300 [*] Yoda conditions are discouraged, use `age < YODA` instead +SIM300.py:11:1: SIM300 [*] Yoda condition detected | 9 | +42 > age # SIM300 10 | YODA == age # SIM300 @@ -195,7 +195,7 @@ SIM300.py:11:1: SIM300 [*] Yoda conditions are discouraged, use `age < YODA` ins 12 | YODA >= age # SIM300 13 | JediOrder.YODA == age # SIM300 | - = help: Replace Yoda condition with `age < YODA` + = help: Rewrite as `age < YODA` ℹ Safe fix 8 8 | -42 > age # SIM300 @@ -207,7 +207,7 @@ SIM300.py:11:1: SIM300 [*] Yoda conditions are discouraged, use `age < YODA` ins 13 13 | JediOrder.YODA == age # SIM300 14 14 | 0 < (number - 100) # SIM300 -SIM300.py:12:1: SIM300 [*] Yoda conditions are discouraged, use `age <= YODA` instead +SIM300.py:12:1: SIM300 [*] Yoda condition detected | 10 | YODA == age # SIM300 11 | YODA > age # SIM300 @@ -216,7 +216,7 @@ SIM300.py:12:1: SIM300 [*] Yoda conditions are discouraged, use `age <= YODA` in 13 | JediOrder.YODA == age # SIM300 14 | 0 < (number - 100) # SIM300 | - = help: Replace Yoda condition with `age <= YODA` + = help: Rewrite as `age <= YODA` ℹ Safe fix 9 9 | +42 > age # SIM300 @@ -228,7 +228,7 @@ SIM300.py:12:1: SIM300 [*] Yoda conditions are discouraged, use `age <= YODA` in 14 14 | 0 < (number - 100) # SIM300 15 15 | B age # SIM300 12 | YODA >= age # SIM300 @@ -237,7 +237,7 @@ SIM300.py:13:1: SIM300 [*] Yoda conditions are discouraged, use `age == JediOrde 14 | 0 < (number - 100) # SIM300 15 | B 0` instead +SIM300.py:14:1: SIM300 [*] Yoda condition detected | 12 | YODA >= age # SIM300 13 | JediOrder.YODA == age # SIM300 @@ -258,7 +258,7 @@ SIM300.py:14:1: SIM300 [*] Yoda conditions are discouraged, use `(number - 100) 15 | B 0` + = help: Rewrite as `(number - 100) > 0` ℹ Safe fix 11 11 | YODA > age # SIM300 @@ -270,7 +270,7 @@ SIM300.py:14:1: SIM300 [*] Yoda conditions are discouraged, use `(number - 100) 16 16 | B or(B) B` instead +SIM300.py:15:1: SIM300 [*] Yoda condition detected | 13 | JediOrder.YODA == age # SIM300 14 | 0 < (number - 100) # SIM300 @@ -278,7 +278,7 @@ SIM300.py:15:1: SIM300 [*] Yoda conditions are discouraged, use `A[0][0] > B` in | ^^^^^^^^^ SIM300 16 | B or(B) B` + = help: Rewrite as `A[0][0] > B` ℹ Safe fix 12 12 | YODA >= age # SIM300 @@ -290,7 +290,7 @@ SIM300.py:15:1: SIM300 [*] Yoda conditions are discouraged, use `A[0][0] > B` in 17 17 | 18 18 | # Errors in preview -SIM300.py:16:5: SIM300 [*] Yoda conditions are discouraged, use `A[0][0] > (B)` instead +SIM300.py:16:5: SIM300 [*] Yoda condition detected | 14 | 0 < (number - 100) # SIM300 15 | B (B)` 17 | 18 | # Errors in preview | - = help: Replace Yoda condition with `A[0][0] > (B)` + = help: Rewrite as `A[0][0] > (B)` ℹ Safe fix 13 13 | JediOrder.YODA == age # SIM300 @@ -311,44 +311,42 @@ SIM300.py:16:5: SIM300 [*] Yoda conditions are discouraged, use `A[0][0] > (B)` 18 18 | # Errors in preview 19 19 | ['upper'] == UPPER_LIST -SIM300.py:23:1: SIM300 [*] Yoda conditions are discouraged, use `['upper'] == UPPER_LIST` instead +SIM300.py:19:1: SIM300 [*] Yoda condition detected | -22 | # Errors in stable -23 | UPPER_LIST == ['upper'] +18 | # Errors in preview +19 | ['upper'] == UPPER_LIST | ^^^^^^^^^^^^^^^^^^^^^^^ SIM300 -24 | DummyHandler.CONFIG == {} +20 | {} == DummyHandler.CONFIG | - = help: Replace Yoda condition with `['upper'] == UPPER_LIST` + = help: Rewrite as `UPPER_LIST == ['upper']` ℹ Safe fix +16 16 | B or(B) age # SIM300 - -SIM300.py:5:1: SIM300 [*] Yoda conditions are discouraged, use `compare >= "yoda"` instead - | -3 | 42 == age # SIM300 -4 | ("a", "b") == compare # SIM300 -5 | "yoda" <= compare # SIM300 - | ^^^^^^^^^^^^^^^^^ SIM300 -6 | "yoda" < compare # SIM300 -7 | 42 > age # SIM300 - | - = help: Replace Yoda condition with `compare >= "yoda"` - -ℹ Safe fix -2 2 | "yoda" == compare # SIM300 -3 3 | 42 == age # SIM300 -4 4 | ("a", "b") == compare # SIM300 -5 |-"yoda" <= compare # SIM300 - 5 |+compare >= "yoda" # SIM300 -6 6 | "yoda" < compare # SIM300 -7 7 | 42 > age # SIM300 -8 8 | -42 > age # SIM300 - -SIM300.py:6:1: SIM300 [*] Yoda conditions are discouraged, use `compare > "yoda"` instead - | -4 | ("a", "b") == compare # SIM300 -5 | "yoda" <= compare # SIM300 -6 | "yoda" < compare # SIM300 - | ^^^^^^^^^^^^^^^^ SIM300 -7 | 42 > age # SIM300 -8 | -42 > age # SIM300 - | - = help: Replace Yoda condition with `compare > "yoda"` - -ℹ Safe fix -3 3 | 42 == age # SIM300 -4 4 | ("a", "b") == compare # SIM300 -5 5 | "yoda" <= compare # SIM300 -6 |-"yoda" < compare # SIM300 - 6 |+compare > "yoda" # SIM300 -7 7 | 42 > age # SIM300 -8 8 | -42 > age # SIM300 -9 9 | +42 > age # SIM300 - -SIM300.py:7:1: SIM300 [*] Yoda conditions are discouraged, use `age < 42` instead - | -5 | "yoda" <= compare # SIM300 -6 | "yoda" < compare # SIM300 -7 | 42 > age # SIM300 - | ^^^^^^^^ SIM300 -8 | -42 > age # SIM300 -9 | +42 > age # SIM300 - | - = help: Replace Yoda condition with `age < 42` - -ℹ Safe fix -4 4 | ("a", "b") == compare # SIM300 -5 5 | "yoda" <= compare # SIM300 -6 6 | "yoda" < compare # SIM300 -7 |-42 > age # SIM300 - 7 |+age < 42 # SIM300 -8 8 | -42 > age # SIM300 -9 9 | +42 > age # SIM300 -10 10 | YODA == age # SIM300 - -SIM300.py:8:1: SIM300 [*] Yoda conditions are discouraged, use `age < -42` instead - | - 6 | "yoda" < compare # SIM300 - 7 | 42 > age # SIM300 - 8 | -42 > age # SIM300 - | ^^^^^^^^^ SIM300 - 9 | +42 > age # SIM300 -10 | YODA == age # SIM300 - | - = help: Replace Yoda condition with `age < -42` - -ℹ Safe fix -5 5 | "yoda" <= compare # SIM300 -6 6 | "yoda" < compare # SIM300 -7 7 | 42 > age # SIM300 -8 |--42 > age # SIM300 - 8 |+age < -42 # SIM300 -9 9 | +42 > age # SIM300 -10 10 | YODA == age # SIM300 -11 11 | YODA > age # SIM300 - -SIM300.py:9:1: SIM300 [*] Yoda conditions are discouraged, use `age < +42` instead - | - 7 | 42 > age # SIM300 - 8 | -42 > age # SIM300 - 9 | +42 > age # SIM300 - | ^^^^^^^^^ SIM300 -10 | YODA == age # SIM300 -11 | YODA > age # SIM300 - | - = help: Replace Yoda condition with `age < +42` - -ℹ Safe fix -6 6 | "yoda" < compare # SIM300 -7 7 | 42 > age # SIM300 -8 8 | -42 > age # SIM300 -9 |-+42 > age # SIM300 - 9 |+age < +42 # SIM300 -10 10 | YODA == age # SIM300 -11 11 | YODA > age # SIM300 -12 12 | YODA >= age # SIM300 - -SIM300.py:10:1: SIM300 [*] Yoda conditions are discouraged, use `age == YODA` instead - | - 8 | -42 > age # SIM300 - 9 | +42 > age # SIM300 -10 | YODA == age # SIM300 - | ^^^^^^^^^^^ SIM300 -11 | YODA > age # SIM300 -12 | YODA >= age # SIM300 - | - = help: Replace Yoda condition with `age == YODA` - -ℹ Safe fix -7 7 | 42 > age # SIM300 -8 8 | -42 > age # SIM300 -9 9 | +42 > age # SIM300 -10 |-YODA == age # SIM300 - 10 |+age == YODA # SIM300 -11 11 | YODA > age # SIM300 -12 12 | YODA >= age # SIM300 -13 13 | JediOrder.YODA == age # SIM300 - -SIM300.py:11:1: SIM300 [*] Yoda conditions are discouraged, use `age < YODA` instead - | - 9 | +42 > age # SIM300 -10 | YODA == age # SIM300 -11 | YODA > age # SIM300 - | ^^^^^^^^^^ SIM300 -12 | YODA >= age # SIM300 -13 | JediOrder.YODA == age # SIM300 - | - = help: Replace Yoda condition with `age < YODA` - -ℹ Safe fix -8 8 | -42 > age # SIM300 -9 9 | +42 > age # SIM300 -10 10 | YODA == age # SIM300 -11 |-YODA > age # SIM300 - 11 |+age < YODA # SIM300 -12 12 | YODA >= age # SIM300 -13 13 | JediOrder.YODA == age # SIM300 -14 14 | 0 < (number - 100) # SIM300 - -SIM300.py:12:1: SIM300 [*] Yoda conditions are discouraged, use `age <= YODA` instead - | -10 | YODA == age # SIM300 -11 | YODA > age # SIM300 -12 | YODA >= age # SIM300 - | ^^^^^^^^^^^ SIM300 -13 | JediOrder.YODA == age # SIM300 -14 | 0 < (number - 100) # SIM300 - | - = help: Replace Yoda condition with `age <= YODA` - -ℹ Safe fix -9 9 | +42 > age # SIM300 -10 10 | YODA == age # SIM300 -11 11 | YODA > age # SIM300 -12 |-YODA >= age # SIM300 - 12 |+age <= YODA # SIM300 -13 13 | JediOrder.YODA == age # SIM300 -14 14 | 0 < (number - 100) # SIM300 -15 15 | B age # SIM300 -12 | YODA >= age # SIM300 -13 | JediOrder.YODA == age # SIM300 - | ^^^^^^^^^^^^^^^^^^^^^ SIM300 -14 | 0 < (number - 100) # SIM300 -15 | B age # SIM300 -12 12 | YODA >= age # SIM300 -13 |-JediOrder.YODA == age # SIM300 - 13 |+age == JediOrder.YODA # SIM300 -14 14 | 0 < (number - 100) # SIM300 -15 15 | B 0` instead - | -12 | YODA >= age # SIM300 -13 | JediOrder.YODA == age # SIM300 -14 | 0 < (number - 100) # SIM300 - | ^^^^^^^^^^^^^^^^^^ SIM300 -15 | B 0` - -ℹ Safe fix -11 11 | YODA > age # SIM300 -12 12 | YODA >= age # SIM300 -13 13 | JediOrder.YODA == age # SIM300 -14 |-0 < (number - 100) # SIM300 - 14 |+(number - 100) > 0 # SIM300 -15 15 | B B` instead - | -13 | JediOrder.YODA == age # SIM300 -14 | 0 < (number - 100) # SIM300 -15 | B B` - -ℹ Safe fix -12 12 | YODA >= age # SIM300 -13 13 | JediOrder.YODA == age # SIM300 -14 14 | 0 < (number - 100) # SIM300 -15 |-B B or B -16 16 | B or(B) (B)` instead - | -14 | 0 < (number - 100) # SIM300 -15 | B (B)` - -ℹ Safe fix -13 13 | JediOrder.YODA == age # SIM300 -14 14 | 0 < (number - 100) # SIM300 -15 15 | B (B) -17 17 | -18 18 | # Errors in preview -19 19 | ['upper'] == UPPER_LIST - -SIM300.py:19:1: SIM300 [*] Yoda conditions are discouraged, use `UPPER_LIST == ['upper']` instead - | -18 | # Errors in preview -19 | ['upper'] == UPPER_LIST - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM300 -20 | {} == DummyHandler.CONFIG - | - = help: Replace Yoda condition with `UPPER_LIST == ['upper']` - -ℹ Safe fix -16 16 | B or(B)