Skip to content

Commit

Permalink
SIM111: Fix false-positive (#124)
Browse files Browse the repository at this point in the history
Closes #62
  • Loading branch information
MartinThoma committed Mar 28, 2022
1 parent 91f371f commit 216afdc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion flake8_simplify/rules/ast_for.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def get_sim110_sim111(node: ast.For) -> List[Tuple[int, int, str]]:
return errors
if not hasattr(node.body[0].body[0].value, "value"):
return errors
if isinstance(node.next_sibling, ast.Raise): # type: ignore
if not isinstance(node.next_sibling, ast.Return): # type: ignore
return errors
check = to_source(node.body[0].test)
target = to_source(node.target)
Expand Down
12 changes: 12 additions & 0 deletions tests/test_100_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,3 +498,15 @@ def test_sim120():
assert results == {
"1:0 SIM120 Use 'class FooBar:' instead of 'class FooBar(object):'"
}


def test_sim111_false_positive():
results = _results(
"""for a in my_list:
if a == 2:
return False
call_method()
return True"""
)
for el in results:
assert "SIM111" not in el

0 comments on commit 216afdc

Please sign in to comment.