-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Omit no-member error if guarded behind if stmt #4764
Conversation
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.
I'm surprised that this does not break more functional tests. I think this is a nice way to remove some false positive using astroid inference.
# Don't emit no-member if guarded behind `IF` or `IFExp` | ||
# * Walk up recursively until if statement is found. | ||
# * Check if condition can be inferred as `Const`, | ||
# would evaluate as `False`, |
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.
That's pretty clever.
Type of Changes
Description
Omit
no-member
errors if attribute / method access is guarded behind if statement.This change doesn't implement
control-flow
logic. Instead I chose to check for anIF
/IFExp
node in the node parents and evaluate it. That doesn't solve all issue, especially not those withassert
#4693, but I would never the less consider it an improvement.As this is a larger change, I would like to target
2.10
for it.Example
--
Ref #1162 (not closed, but issue would be addressed)
Closes #1990
Closes #4168