-
-
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
Implemented unused-private-member
checker
#4504
Conversation
e11c9f1
to
5639244
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.
Thank you for this new checker, it will permit to clean up a lot of unused code in badly tested code bases !
def __my_print(self, string): | ||
print(self.__another_secret + string) | ||
another_obj = AnotherClass() | ||
another_obj.__test() # this class's test should still be unused |
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.
👍
pylint/checkers/classes.py
Outdated
@@ -636,6 +636,11 @@ def _has_same_layout_slots(slots, assigned_value): | |||
"Used when a method parameter has a different name than in " | |||
"the implemented interface or in an overridden method.", | |||
), | |||
"W0238": ( | |||
"Unused private member of class %s: %s", |
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.
"Unused private member of class %s: %s", | |
"Unused private member '%s.%s'", |
I found a false positive. It's not that common for python, but at times used for the singleton pattern. class MyCls:
__class_var = None
@classmethod
def set_class_var(cls, var):
cls.__class_var = var # false-positive: unused-private-member
@classmethod
def get_class_var(cls):
return cls.__class_var |
I'll look into this |
Steps
doc/whatsnew/<current release.rst>
.Description
Implemented
unused-private-member
checker, which is emitted when a private member of a class is defined but unusedChecks for:
Type of Changes
Related Issue
Closes #4483