I have code that looks like this:
Class Parent:
def someMethod(self):
return 42
Class Child(Parent):
def someMethod(self):
print self.answer
The parent has a method that could be static, and (to get rid of Pylint warnings) I want to add a @staticmethod decorator, but then I would want to remove self as an argument. That would mean the Parent and Child have different input arguments. Is there any good way to do this besides leaving the code as is?
If you want to be able to pass a Child when a Parent is expected, then the overriding method should accept the same argument list as the parent’s method. It just happens that this specific Parent implementation that method could be made static.
Use a
# pylint: disable=X0123(replace with the appropriate warning code) in the parent to disable the lint warning.