From 212ce4d331d18295755dcb28dd87b0a6d3fba26c Mon Sep 17 00:00:00 2001 From: Chammika Mannakkara Date: Sun, 8 Jan 2023 12:03:48 +0900 Subject: [PATCH] buf-fix: flake8_simplify SIM212 (#1732) bug-fix in #1717 Use the correct `IfExprWithTwistedArms` struct. --- src/flake8_simplify/plugins/ast_ifexp.rs | 2 +- ...ke8_simplify__tests__SIM212_SIM212.py.snap | 22 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/flake8_simplify/plugins/ast_ifexp.rs b/src/flake8_simplify/plugins/ast_ifexp.rs index 03a93f3924a0e..7db0df4d7bfad 100644 --- a/src/flake8_simplify/plugins/ast_ifexp.rs +++ b/src/flake8_simplify/plugins/ast_ifexp.rs @@ -120,7 +120,7 @@ pub fn twisted_arms_in_ifexpr( } let mut check = Check::new( - violations::NegateEqualOp( + violations::IfExprWithTwistedArms( unparse_expr(body, checker.style), unparse_expr(orelse, checker.style), ), diff --git a/src/flake8_simplify/snapshots/ruff__flake8_simplify__tests__SIM212_SIM212.py.snap b/src/flake8_simplify/snapshots/ruff__flake8_simplify__tests__SIM212_SIM212.py.snap index 0fd162503d27f..600ee47fe5c66 100644 --- a/src/flake8_simplify/snapshots/ruff__flake8_simplify__tests__SIM212_SIM212.py.snap +++ b/src/flake8_simplify/snapshots/ruff__flake8_simplify__tests__SIM212_SIM212.py.snap @@ -3,7 +3,7 @@ source: src/flake8_simplify/mod.rs expression: checks --- - kind: - NegateEqualOp: + IfExprWithTwistedArms: - b - a location: @@ -12,10 +12,17 @@ expression: checks end_location: row: 1 column: 21 - fix: ~ + fix: + content: a if a else b + location: + row: 1 + column: 4 + end_location: + row: 1 + column: 21 parent: ~ - kind: - NegateEqualOp: + IfExprWithTwistedArms: - b + c - a location: @@ -24,6 +31,13 @@ expression: checks end_location: row: 3 column: 25 - fix: ~ + fix: + content: a if a else b + c + location: + row: 3 + column: 4 + end_location: + row: 3 + column: 25 parent: ~