[Python-projects] W0613 false positives on inherited arguments
Maarten ter Huurne
maarten at treewalker.org
Wed Dec 3 01:17:21 CET 2008
Hi,
Please look at the method arguments in the following program:
===
class Base(object):
def inherited(self, aa, ab, ac):
raise NotImplementedError
class Sub(Base):
def inherited(self, aa, ab, ac):
return aa
def newmethod(self, ax, ay):
print ax
===
pylint will warn about 3 unused arguments:
===
W0613: 8:Sub.inherited: Unused argument 'ab'
W0613: 8:Sub.inherited: Unused argument 'ac'
W0613: 11:Sub.newmethod: Unused argument 'ay'
===
Of these, the warning for "ay" is desired. The warnings for "ab" and "ac"
are most likely false positives though, because there could be another
subclass that overrides the same method and does use the arguments:
===
class Sub2(Base):
def inherited(self, aa, ab, ac):
return aa + ab + ac
===
So I propose to not report W0613 for inherited arguments. I made a patch
that implements this proposal, it is attached. The patch might need some
cleaning up, but I hope it offers a useful starting point.
Bye,
Maarten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: variables.diff
Type: text/x-patch
Size: 1185 bytes
Desc: not available
Url : http://lists.logilab.org/pipermail/python-projects/attachments/20081203/680df927/attachment.bin
More information about the Python-Projects
mailing list