diff options
-rwxr-xr-x | checkers/base.py | 2 | ||||
-rw-r--r-- | checkers/classes.py | 15 | ||||
-rw-r--r-- | checkers/variables.py | 8 |
3 files changed, 13 insertions, 12 deletions
diff --git a/checkers/base.py b/checkers/base.py index 73d8089..82a623f 100755 --- a/checkers/base.py +++ b/checkers/base.py @@ -409,7 +409,7 @@ functions, methods for i in xrange(len(ordinary_args)): if not isinstance(call.args[i], astng.Name): return - if node.args.args[i] != call.args[i].name: + if node.args.args[i].name != call.args[i].name: return self.add_message('W0108', line=node.lineno, node=node) diff --git a/checkers/classes.py b/checkers/classes.py index eacb116..200f5aa 100644 --- a/checkers/classes.py +++ b/checkers/classes.py @@ -350,25 +350,26 @@ instance attributes.'} # don't care about functions with unknown argument (builtins) if node.args.args is None: return - self._first_attrs.append(node.args.args and node.args.args[0]) + first = node.argnames()[0] + self._first_attrs.append(first) # static method if node.type == 'staticmethod': - if node.args.args and node.args.args[0] in ('self', 'cls', 'mcs'): - self.add_message('W0211', args=node.args.args[0], node=node) + if first in ('self', 'cls', 'mcs'): + self.add_message('W0211', args=first, node=node) self._first_attrs[-1] = None # class / regular method with no args - elif not node.args.args: + elif not first: self.add_message('E0211', node=node) # metaclass method elif metaclass: - if self._first_attrs[-1] != 'mcs': + if first != 'mcs': self.add_message('C0203', node=node) # class method elif node.type == 'classmethod': - if self._first_attrs[-1] != 'cls': + if first != 'cls': self.add_message('C0202', node=node) # regular method without self as argument - elif self._first_attrs[-1] != 'self': + elif first != 'self': self.add_message('E0213', node=node) def _check_bases_classes(self, node): diff --git a/checkers/variables.py b/checkers/variables.py index 515c450..d97518c 100644 --- a/checkers/variables.py +++ b/checkers/variables.py @@ -230,7 +230,7 @@ builtins. Remember that you should avoid to define new builtins when possible.' return authorized_rgx = self.config.dummy_variables_rgx overridden = marker = [] - args = node.args.args + argnames = node.argnames() for name, stmts in not_consumed.iteritems(): # ignore some special names specified by user configuration if authorized_rgx.match(name): @@ -241,15 +241,15 @@ builtins. Remember that you should avoid to define new builtins when possible.' if isinstance(stmt, astng.Global): continue # care about functions with unknown argument (builtins) - if args and name in args: + if name in argnames: if is_method: # don't warn for the first argument of a (non static) method - if node.type != 'staticmethod' and name == args[0]: + if node.type != 'staticmethod' and name == argnames[0]: continue # don't warn for argument of an overridden method if overridden is marker: overridden = overridden_method(klass, node.name) - if overridden is not None and name in overridden.args.args: + if overridden is not None and name in overridden.argnames(): continue # don't check callback arguments if node.name.startswith('cb_') or \ |