diff --git a/flake8_simplify/rules/ast_for.py b/flake8_simplify/rules/ast_for.py index fcbac36..8d4d984 100644 --- a/flake8_simplify/rules/ast_for.py +++ b/flake8_simplify/rules/ast_for.py @@ -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) diff --git a/tests/test_100_rules.py b/tests/test_100_rules.py index 2164e31..fba08fe 100644 --- a/tests/test_100_rules.py +++ b/tests/test_100_rules.py @@ -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