-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix false positive undefined variable in decorator with list comprehe…
- Loading branch information
Showing
4 changed files
with
30 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ | |
# Copyright (c) 2021 Lorena B <[email protected]> | ||
# Copyright (c) 2021 haasea <[email protected]> | ||
# Copyright (c) 2021 Alexander Kapshuna <[email protected]> | ||
# Copyright (c) 2021 Marcin Kurczewski <[email protected]> | ||
|
||
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html | ||
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE | ||
|
@@ -1006,9 +1007,12 @@ def visit_name(self, node): | |
# variable used outside the loop | ||
# avoid the case where there are homonyms inside function scope and | ||
# comprehension current scope (avoid bug #1731) | ||
if name in current_consumer.consumed and not ( | ||
current_consumer.scope_type == "comprehension" | ||
and self._has_homonym_in_upper_function_scope(node, i) | ||
if name in current_consumer.consumed and ( | ||
utils.is_func_decorator(current_consumer.node) | ||
or not ( | ||
current_consumer.scope_type == "comprehension" | ||
and self._has_homonym_in_upper_function_scope(node, i) | ||
) | ||
): | ||
defnode = utils.assign_parent(current_consumer.consumed[name][0]) | ||
self._check_late_binding_closure(node, defnode) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters