[Python-projects] pylint #9263: no W0613 for __init__, thoughts on fix

Colin Morris colin.morris2 at gmail.com
Sun Feb 28 10:39:22 CET 2010


Hi,

I've been looking at pylint ticket
#9263<https://www.logilab.net/elo/ticket/9263>(no W0613 for __init__
(method does not use all of its arguments)). It looks
like the problem occurs in the variables checker, at line 243, when the
checker gives the method a pass if it's in PYMETHODS, a set of special
Python functions. __init__ is in PYMETHODS, so it's never subject to W0613
warnings. I think the check is still valuable for almost all other methods
in PYMETHODS, where the number of arguments is fixed. For example, it seems
reasonable that someone might want to define some object with infinite
magnitude, and override its __ge__ method to just return True -- but because
__gt__ must take two arguments, including self, having an unused argument is
unavoidable.

As far as I can tell, the only two methods in PYMETHODS where it's still
desirable to check for unused arguments would be __init__ and __new__.
PYMETHODS is used by other checkers, so changing it doesn't seem like a
possibility. My proposed solution would be to just add another condition to
243 so that it reads something like "if node.name in PYMETHODS and
node.namenot in ('__init__', '__new__'):". Does this seem like a
reasonable fix?

Regards,
--
Colin Morris
Team Tahiti
University of Toronto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.logilab.org/pipermail/python-projects/attachments/20100228/1eca77f5/attachment.html>


More information about the Python-Projects mailing list