-
-
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
Simplistic method to detect possible undefined vars #8797
Simplistic method to detect possible undefined vars #8797
Conversation
@@ -0,0 +1,21 @@ | |||
"""module docstring""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both these test files are only to ease debugging, will be deleted
for more information, see https://pre-commit.ci
Hi @alonme thanks for this. In #1727 (comment) I was suggesting something along the lines of this, did you investigate it yet? It fixes the issue but haven't checked the test suite or the primer result. diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py
index 3ea2d04a5..ab7ed9618 100644
--- a/pylint/checkers/variables.py
+++ b/pylint/checkers/variables.py
@@ -735,13 +735,13 @@ scope_type : {self._atomic.scope_type}
# Only search else branch when test condition is inferred to be false
if all_inferred and only_search_else:
return NamesConsumer._branch_handles_name(name, node.orelse)
- # Only search if branch when test condition is inferred to be true
- if all_inferred and only_search_if:
- return NamesConsumer._branch_handles_name(name, node.body)
+ # # Only search if branch when test condition is inferred to be true
+ # if all_inferred and only_search_if:
+ # return NamesConsumer._branch_handles_name(name, node.body)
# Search both if and else branches
return NamesConsumer._branch_handles_name(
name, node.body
- ) or NamesConsumer._branch_handles_name(name, node.orelse)
+ ) and NamesConsumer._branch_handles_name(name, node.orelse)
@staticmethod
def _branch_handles_name(name: str, body: Iterable[nodes.NodeNG]) -> bool: |
Closing in favor of #8952 |
Type of Changes
Description
Closes #1727