Skip to content

Commit ebb64fc

Browse files
author
Sylvain Thénault
committed
applied Colin Moris patch closing #9263: no W0613 for __init__ (method does not use all of its arguments)
1 parent 44fc24c commit ebb64fc

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

checkers/variables.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def leave_function(self, node):
240240
overridden = overridden_method(klass, node.name)
241241
if overridden is not None and name in overridden.argnames():
242242
continue
243-
if node.name in PYMETHODS:
243+
if node.name in PYMETHODS and node.name not in ('__init__', '__new__'):
244244
continue
245245
# don't check callback arguments XXX should be configurable
246246
if node.name.startswith('cb_') or node.name.endswith('_cb'):

test/input/func_w0613.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def selected(cls, *args, **kwargs):
2222
"""called by the registry when the vobject has been selected.
2323
"""
2424
return cls
25-
25+
2626
def using_inner_function(self, etype, size=1):
2727
"""return a fake result set for a particular entity type"""
2828
rset = AAAA([('A',)]*size, '%s X' % etype,
@@ -33,3 +33,11 @@ def inner(row, col=0, etype=etype, req=self, rset=rset):
3333
return req.vreg.etype_class(etype)(req, rset, row, col)
3434
# pylint: disable-msg = W0201
3535
rset.get_entity = inner
36+
37+
class BBBB:
38+
"""dummy class"""
39+
40+
def __init__(self, arg):
41+
"""Constructor with an extra parameter. Should raise a warning"""
42+
self.spam = 1
43+

test/messages/func_w0613.txt

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ W: 7:function: Unused argument 'arg'
22
W: 14:AAAA.method: Unused argument 'arg'
33
W: 21:AAAA.selected: Unused argument 'args'
44
W: 21:AAAA.selected: Unused argument 'kwargs'
5+
W: 40:BBBB.__init__: Unused argument 'arg'

0 commit comments

Comments
 (0)