Related #5496
I recently came across code like this
class Parent:
@staticmethod
def get_email() -> str:
return "test@test.com"
class Child(Parent):
def __init__(self, email: str) -> None:
self.email = email
def get_email(self) -> str:
return self.email
def func(x: Parent):
print(x.get_email())
Although get_email is only ever called on an instance, the author choose to add the staticmethod decorator. I believe, just so pylint wouldn't complain about no-self-use.
With #5412 this will however now emit a arguments-differ warning on Child.get_email (with and without staticmethod).
Proposal
I would like to propose moving no-self-use to an optional checker.
Reason
Although this check might be helpful in some instances, usually not using self is no indication that a method should be static. As shown in the example, sometimes this leads to devs writing worse code just to satisfy pylint instead of adding pylint: disable.
Related #5496
I recently came across code like this
Although
get_emailis only ever called on an instance, the author choose to add thestaticmethoddecorator. I believe, just so pylint wouldn't complain aboutno-self-use.With #5412 this will however now emit a
arguments-differwarning onChild.get_email(with and withoutstaticmethod).Proposal
I would like to propose moving
no-self-useto an optional checker.Reason
Although this check might be helpful in some instances, usually not using
selfis no indication that a method should bestatic. As shown in the example, sometimes this leads to devs writing worse code just to satisfy pylint instead of addingpylint: disable.