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 false-positive of unused-private-member
with class name
#4782
Fix false-positive of unused-private-member
with class name
#4782
Conversation
df706ee
to
f46af19
Compare
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.
Left some comments. Additionally I noticed that _check_unused_private_attributes
doesn't have typing.cast
after nodes_of_class
. Maybe you would like to add it with this change (two times).
--
One more thing, just so you know. For PRs it doesn't make much sense to assign yourself if you are already the author. I usually assign myself if I want to show that I'll review a PR from someone else and what to help see it through.
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.
Looks good! I also like the additional test case you added π
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.
Thank you !
Hello there! Shouldn't this PR also fix: class UnusedPrivateMember:
"""unused-private-member (W0238)"""
@staticmethod
def __private_method():
"""Is private and does nothing."""
@classmethod
def use_private_method(cls):
"""Calls private method."""
cls.__private_method() which produces:
I'm running the latest master branch:
Note, when using a class attribute (i.e. change |
@yumasheta Can you open a new issue for it? That way we are better able to track it |
Type of Changes
Description
Simple fix to avoid false-positive to check for private attributes and do not emit if it was called with the Class's name.
Done by using a boolean condition and comparing it to the node's (classdef) name
Also, added a pylint ignore as more boolean expressions are needed here
Closes #4681