diff options
| author | Anthony Sottile <asottile@umich.edu> | 2018-05-22 00:35:46 -0700 |
|---|---|---|
| committer | Claudiu Popa <pcmanticore@gmail.com> | 2018-05-22 09:37:37 +0200 |
| commit | 6b4c4d24f15ebaf0d08e42984329ee56a0a3d207 (patch) | |
| tree | 64d762df5c94f4b7a701a172b33a2a200c8901eb /pylint/checkers/python3.py | |
| parent | 3896ed627009f9547d1ca7fbf7d2d1156e0e89ad (diff) | |
| download | pylint-git-6b4c4d24f15ebaf0d08e42984329ee56a0a3d207.tar.gz | |
Use last previous assignment for comprehension-escape (#2131)
Diffstat (limited to 'pylint/checkers/python3.py')
| -rw-r--r-- | pylint/checkers/python3.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/pylint/checkers/python3.py b/pylint/checkers/python3.py index 1e988f63b..f2efa18d1 100644 --- a/pylint/checkers/python3.py +++ b/pylint/checkers/python3.py @@ -638,9 +638,10 @@ class Python3Checker(checkers.BaseChecker): # On Python 3 we don't find the leaked objects as # they are already deleted, so instead look for them manually. scope = node.scope() - assign_names = (node_ for node_ in scope.nodes_of_class(astroid.AssignName) - if node_.name == node.name and node_.lineno < node.lineno) - assigned = next(assign_names, None) + assigned = None + for node_ in scope.nodes_of_class(astroid.AssignName): + if node_.name == node.name and node_.lineno < node.lineno: + assigned = node_ if not assigned: return |
