Skip to content

Commit

Permalink
Tweak fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Jan 7, 2023
1 parent d490e47 commit 32432c6
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 58 deletions.
11 changes: 4 additions & 7 deletions resources/test/fixtures/flake8_simplify/SIM210.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
a = True if b else False # SIM210

a = True if b else False # SIM210

a = True if b!=c else False # SIM210

a = True if b+c else False # SIM210

a = False if b else True
a = True if b != c else False # SIM210

a = True if b + c else False # SIM210

a = False if b else True # OK
11 changes: 4 additions & 7 deletions resources/test/fixtures/flake8_simplify/SIM211.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
a = False if b else True # SIM211

a = False if b else True # SIM211

a = False if b!=c else True # SIM211 -> SIM201

a = False if b+c else True # SIM211

a = True if b else False
a = False if b != c else True # SIM211

a = False if b + c else True # SIM211

a = True if b else False # OK
10 changes: 4 additions & 6 deletions resources/test/fixtures/flake8_simplify/SIM212.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
c = b if not a else a # SIM212

c = b if not a else a # SIM212
c = b + c if not a else a # SIM212

c = b+c if not a else a # SIM212

c = b if not x else a

c = a if a else b
c = b if not x else a # OK

c = a if a else b # OK
3 changes: 2 additions & 1 deletion src/flake8_simplify/plugins/ast_ifexp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ pub fn twisted_arms_in_ifexpr(
if !matches!(op, Unaryop::Not) {
return;
}
// Check if test operand and else branch is the same named variable

// Check if the test operand and else branch use the same variable.
let ExprKind::Name { id: test_id, .. } = &test_operand.node else {
return;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,52 @@ expression: checks
- kind:
IfExprWithTrueFalse: b
location:
row: 2
row: 1
column: 4
end_location:
row: 2
row: 1
column: 24
fix:
content: bool(b)
location:
row: 2
row: 1
column: 4
end_location:
row: 2
row: 1
column: 24
parent: ~
- kind:
IfExprWithTrueFalse: b != c
location:
row: 4
row: 3
column: 4
end_location:
row: 4
column: 27
row: 3
column: 29
fix:
content: bool(b != c)
location:
row: 4
row: 3
column: 4
end_location:
row: 4
column: 27
row: 3
column: 29
parent: ~
- kind:
IfExprWithTrueFalse: b + c
location:
row: 6
row: 5
column: 4
end_location:
row: 6
column: 26
row: 5
column: 28
fix:
content: bool(b + c)
location:
row: 6
row: 5
column: 4
end_location:
row: 6
column: 26
row: 5
column: 28
parent: ~

Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,52 @@ expression: checks
- kind:
IfExprWithFalseTrue: b
location:
row: 2
row: 1
column: 4
end_location:
row: 2
row: 1
column: 24
fix:
content: not b
location:
row: 2
row: 1
column: 4
end_location:
row: 2
row: 1
column: 24
parent: ~
- kind:
IfExprWithFalseTrue: b != c
location:
row: 4
row: 3
column: 4
end_location:
row: 4
column: 27
row: 3
column: 29
fix:
content: not b != c
location:
row: 4
row: 3
column: 4
end_location:
row: 4
column: 27
row: 3
column: 29
parent: ~
- kind:
IfExprWithFalseTrue: b + c
location:
row: 6
row: 5
column: 4
end_location:
row: 6
column: 26
row: 5
column: 28
fix:
content: not b + c
location:
row: 6
row: 5
column: 4
end_location:
row: 6
column: 26
row: 5
column: 28
parent: ~

Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ expression: checks
- b
- a
location:
row: 2
row: 1
column: 4
end_location:
row: 2
row: 1
column: 21
fix: ~
parent: ~
Expand All @@ -19,11 +19,11 @@ expression: checks
- b + c
- a
location:
row: 4
row: 3
column: 4
end_location:
row: 4
column: 23
row: 3
column: 25
fix: ~
parent: ~

0 comments on commit 32432c6

Please sign in to comment.