diff options
-rw-r--r-- | pylint/test/functional/useless_else_on_loop.py | 17 | ||||
-rw-r--r-- | pylint/test/functional/useless_else_on_loop.txt | 2 |
2 files changed, 16 insertions, 3 deletions
diff --git a/pylint/test/functional/useless_else_on_loop.py b/pylint/test/functional/useless_else_on_loop.py index 8fd178798..d686f4658 100644 --- a/pylint/test/functional/useless_else_on_loop.py +++ b/pylint/test/functional/useless_else_on_loop.py @@ -67,8 +67,7 @@ def test_break_in_orelse_deep(): if 3 < 2: break else: - if 1 < 2: - break + break else: return True return False @@ -88,3 +87,17 @@ def test_break_in_orelse_deep2(): else: # [useless-else-on-loop] return True return False + + +def test_break_in_orelse_deep3(): + """no false positive for break deeply nested in else + """ + for _ in range(10): + for _ in range(3): + pass + else: + if 1 < 2: + break + else: + return True + return False diff --git a/pylint/test/functional/useless_else_on_loop.txt b/pylint/test/functional/useless_else_on_loop.txt index 0d561011f..efa1161ab 100644 --- a/pylint/test/functional/useless_else_on_loop.txt +++ b/pylint/test/functional/useless_else_on_loop.txt @@ -3,4 +3,4 @@ useless-else-on-loop:18:test_return_while:Else clause on loop without a break st useless-else-on-loop:28::Else clause on loop without a break statement useless-else-on-loop:35::Else clause on loop without a break statement useless-else-on-loop:40::Else clause on loop without a break statement -useless-else-on-loop:88:test_break_in_orelse_deep2:Else clause on loop without a break statement +useless-else-on-loop:87:test_break_in_orelse_deep2:Else clause on loop without a break statement |