summaryrefslogtreecommitdiff
path: root/tests/functional/u/undefined/undefined_loop_variable.py
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2022-05-01 09:56:08 -0400
committerGitHub <noreply@github.com>2022-05-01 15:56:08 +0200
commitdede647aba2b2c64cd91fdc31fcd682ebfda26cf (patch)
treeb84483438d416f2dc8372244aefec3345a4ef00e /tests/functional/u/undefined/undefined_loop_variable.py
parenteff91ee727bb0f0d7a386d8ae0011cb1b4c3fe63 (diff)
downloadpylint-git-dede647aba2b2c64cd91fdc31fcd682ebfda26cf.tar.gz
Fix a false positive for `undefined-loop-variable` when a loop else raises or returns (#6480)
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'tests/functional/u/undefined/undefined_loop_variable.py')
-rw-r--r--tests/functional/u/undefined/undefined_loop_variable.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/functional/u/undefined/undefined_loop_variable.py b/tests/functional/u/undefined/undefined_loop_variable.py
index 956773e31..94b27d2dd 100644
--- a/tests/functional/u/undefined/undefined_loop_variable.py
+++ b/tests/functional/u/undefined/undefined_loop_variable.py
@@ -91,6 +91,22 @@ def test(content):
handle_line(layne)
+def for_else_returns(iterable):
+ for thing in iterable:
+ break
+ else:
+ return
+ print(thing)
+
+
+def for_else_raises(iterable):
+ for thing in iterable:
+ break
+ else:
+ raise Exception
+ print(thing)
+
+
lst = []
lst2 = [1, 2, 3]