-
-
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
Merged
Pierre-Sassoulas
merged 1 commit into
pylint-dev:main
from
jacobtylerwalls:assign-instance-attribute-to-itself
Mar 25, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"""Tests for no-member for self-referencing instance attributes | ||
See https://github.com/PyCQA/pylint/issues/1555 | ||
""" | ||
# pylint: disable=too-few-public-methods | ||
|
||
|
||
class ClassWithMember: | ||
"""Member defined in superclass.""" | ||
def __init__(self): | ||
self.member = True | ||
|
||
|
||
class AssignMemberInSameLine: | ||
"""This class attempts to assign and access a member in the same line.""" | ||
def __init__(self): | ||
self.member = self.member # [no-member] | ||
|
||
|
||
class AssignMemberInSameLineAfterTypeAnnotation: | ||
"""This might emit a message like `maybe-no-member` in the future.""" | ||
def __init__(self): | ||
self.member: bool | ||
self.member = self.member | ||
|
||
|
||
class AssignMemberFromSuper1(ClassWithMember): | ||
"""This assignment is valid due to inheritance.""" | ||
def __init__(self): | ||
self.member = self.member | ||
super().__init__() | ||
|
||
|
||
class AssignMemberFromSuper2(ClassWithMember): | ||
"""This assignment is valid due to inheritance.""" | ||
def __init__(self): | ||
super().__init__() | ||
self.member = self.member | ||
jacobtylerwalls marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
no-member:16:22:16:33:AssignMemberInSameLine.__init__:Instance of 'AssignMemberInSameLine' has no 'member' member:INFERENCE |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.