summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2021-07-30 21:39:24 +0200
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-08-04 20:34:16 +0200
commitacc0067422a8871429a5889e37b4c5b721a7d0d4 (patch)
tree3ae81474038b3d61c5b6495e15770d4ef13458f0 /tests
parent734965644a5922cead4bbb7c8259498ef7574e20 (diff)
downloadpylint-git-acc0067422a8871429a5889e37b4c5b721a7d0d4.tar.gz
Add regression tests for issue #3711
Diffstat (limited to 'tests')
-rw-r--r--tests/functional/u/undefined/undefined_loop_variable.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/functional/u/undefined/undefined_loop_variable.py b/tests/functional/u/undefined/undefined_loop_variable.py
index a984898f8..317372749 100644
--- a/tests/functional/u/undefined/undefined_loop_variable.py
+++ b/tests/functional/u/undefined/undefined_loop_variable.py
@@ -73,3 +73,33 @@ def do_stuff_with_redefined_range():
for var in range(3):
pass
return var # [undefined-loop-variable]
+
+
+def test(content):
+ # https://github.com/PyCQA/pylint/issues/3711
+ def handle_line(layne):
+ if "X" in layne:
+ layne = layne.replace("X", "Y")
+ elif "Y" in layne: # line 5
+ layne = '{}'.format(layne)
+ elif "Z" in layne: # line 7
+ layne = f'{layne}'
+ else:
+ layne = '%s' % layne # line 10
+
+ for layne in content.split('\n'):
+ handle_line(layne)
+
+
+lst = []
+lst2 = [1, 2, 3]
+
+for item in lst:
+ pass
+
+bigger = [
+ [
+ x for x in lst2 if x > item
+ ]
+ for item in lst
+]