-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix #1555: Fix false negatives for no-member
from self-referencing assignments
#5544
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
Fix #1555: Fix false negatives for no-member
from self-referencing assignments
#5544
Conversation
Pull Request Test Coverage Report for Build 2037093064
💛 - Coveralls |
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.
LGTM, thank you :)
no-member
when assigning instance attribute to itselfno-member
: self-referencing and type annotation only
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.
LGTM, but there's something strange with the coverage report : 86 unchanged lines in 4 files lost coverage.
, do you know why ?
@jacobtylerwalls Thanks for your work again! Looks like you found some additional cases as well. Should we add a test for dataclasses? If we change the comprehension to a for loop that if statement would become uncovered as well (I think). @Pierre-Sassoulas |
That line resulted from fixing failing tests in
See for example #5540. |
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.
@jacobtylerwalls Do you want to do the exception handler move in this PR? Or do it in a later PR?
Edit: I missed your earlier reply. Waiting is fine for me. You make a very good point 😄
We should also wait for a resolution on the astroid
utils
location discussion.
I'm removing this from |
Possible fix for the problems identified here in pylint-dev/astroid#1391 |
@jacobtylerwalls |
Great, thank you for doing the astroid PR! |
@DanielNoord I made the changes, expecting CI to fail, and was greeted by a very unwanted ✅ . What happened? So with that cleaned up, this would crash again before updating astroid (good), but I was still expecting more substantive failures. At first, it looked like I didn't need the newfangled This goes against what you and I discussed here, so it's worth a double-check. Question: Do you think we should move forward with emitting class PossibleNoMember:
def __init__(self):
self.member: bool
def set_member(member):
self.member = member
def depend_on_member():
print(self.member) # should this raise no-member? it will not raise undefined-variable [1] -- These patterns are very intricate -- so after cleaning up the excepts we may be able to write a test case that will require using |
I have a feeling the answer is going to be "create |
#4194 is interesting as well as it fixes #3167, but there is no discussion about this potentially being undefined. I'm not sure. I think we actually use this pattern ourself: Personally I feel that that is worth a message, although as you said perhaps it should be |
no-member
: self-referencing and type annotation onlyno-member
from self-referencing assignments
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.
Need a rebase and moving the changelog to 2.14
…g instance attribute to itself
7d133e3
to
958cc36
Compare
Type of Changes
Description
Emits
no-member
when attempting to assign an instance attribute to itself before it has been defined, since at the moment of attempted assignment, there is no such member.Closes #1555