-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
False positive used-before-assignment
for filtered comprehensions in try blocks
#5586
Comments
@jacobtylerwalls This is one of the final issues in |
I'll let you know this week if I think I can. Meanwhile, I was wondering if you had a gut feeling about this part without having to do much investigation straight away:
And if so, is that in |
Thanks!
diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py
index 66af3ec94..db9c812a7 100644
--- a/pylint/checkers/variables.py
+++ b/pylint/checkers/variables.py
@@ -1316,6 +1316,7 @@ class VariablesChecker(BaseChecker):
if utils.is_func_decorator(current_consumer.node) or not (
current_consumer.scope_type == "comprehension"
and self._has_homonym_in_upper_function_scope(node, consumer_level)
+ and not node.parent in node.parent.parent.ifs
):
self._check_late_binding_closure(node)
self._loopvar_name(node) This raise |
… homonyms in filtered comprehensions and except blocks
…in filtered comprehensions and except blocks (#5666) Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
…ltered comprehensions The prior fixes in pylint-dev#5586 and pylint-dev#5817 still relied on assumptions of direct parentage.
Bug description
Configuration
No response
Command used
Pylint output
Expected behavior
No message.
Here,
found_nodes
for the node inside the generator expression includes the assignment ofvalue
in the except block.https://github.com/PyCQA/pylint/blob/c0fbbb7adbc39cbd67bbd0e0b1ca4e9421c12643/pylint/checkers/variables.py#L611-L620
I'm not sure if the responsibility for filtering that out lies in
to_consume()
; if not, I suppose the newused-before-assignment
logic will have to deal with it.Pylint version
Caused in bd55b27d41542e3ca1f031f986b6151f6cac457f (2.13.0 unreleased)
OS / Environment
No response
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: