| Index: third_party/pylint/checkers/classes.py
|
| diff --git a/third_party/pylint/checkers/classes.py b/third_party/pylint/checkers/classes.py
|
| index eeaf689f440f29545512eabf2eec721090fc5237..1a10c3576d7bdb7ca9079c131fcf845012d6b432 100644
|
| --- a/third_party/pylint/checkers/classes.py
|
| +++ b/third_party/pylint/checkers/classes.py
|
| @@ -30,7 +30,7 @@ from pylint.checkers import BaseChecker
|
| from pylint.checkers.utils import (
|
| PYMETHODS, overrides_a_method, check_messages, is_attr_private,
|
| is_attr_protected, node_frame_class, safe_infer, is_builtin_object,
|
| - decorated_with_property)
|
| + decorated_with_property, unimplemented_abstract_methods)
|
| import six
|
|
|
| if sys.version_info >= (3, 0):
|
| @@ -179,11 +179,11 @@ MSGS = {
|
| 'missing-interface-method',
|
| 'Used when a method declared in an interface is missing from a \
|
| class implementing this interface'),
|
| - 'W0221': ('Arguments number differs from %s method',
|
| + 'W0221': ('Arguments number differs from %s %r method',
|
| 'arguments-differ',
|
| 'Used when a method has a different number of arguments than in \
|
| the implemented interface or in an overridden method.'),
|
| - 'W0222': ('Signature differs from %s method',
|
| + 'W0222': ('Signature differs from %s %r method',
|
| 'signature-differs',
|
| 'Used when a method signature is different than in the \
|
| implemented interface or in an overridden method.'),
|
| @@ -496,7 +496,7 @@ a metaclass class method.'}
|
| if infered is YES:
|
| continue
|
| if (not isinstance(infered, astroid.Const) or
|
| - not isinstance(infered.value, str)):
|
| + not isinstance(infered.value, six.string_types)):
|
| self.add_message('invalid-slots-object',
|
| args=infered.as_string(),
|
| node=elt)
|
| @@ -585,6 +585,8 @@ a metaclass class method.'}
|
| return
|
|
|
| slots = klass.slots()
|
| + if slots is None:
|
| + return
|
| # If any ancestor doesn't use slots, the slots
|
| # defined for this class are superfluous.
|
| if any('__slots__' not in ancestor.locals and
|
| @@ -798,21 +800,28 @@ a metaclass class method.'}
|
| """check that the given class node implements abstract methods from
|
| base classes
|
| """
|
| + def is_abstract(method):
|
| + return method.is_abstract(pass_is_abstract=False)
|
| +
|
| # check if this class abstract
|
| if class_is_abstract(node):
|
| return
|
| - for method in node.methods():
|
| +
|
| + methods = sorted(
|
| + unimplemented_abstract_methods(node, is_abstract).items(),
|
| + key=lambda item: item[0],
|
| + )
|
| + for name, method in methods:
|
| owner = method.parent.frame()
|
| if owner is node:
|
| continue
|
| # owner is not this class, it must be a parent class
|
| # check that the ancestor's method is not abstract
|
| - if method.name in node.locals:
|
| + if name in node.locals:
|
| # it is redefined as an attribute or with a descriptor
|
| continue
|
| - if method.is_abstract(pass_is_abstract=False):
|
| - self.add_message('abstract-method', node=node,
|
| - args=(method.name, owner.name))
|
| + self.add_message('abstract-method', node=node,
|
| + args=(name, owner.name))
|
|
|
| def _check_interfaces(self, node):
|
| """check that the given class node really implements declared
|
| @@ -930,9 +939,13 @@ a metaclass class method.'}
|
| if is_attr_private(method1.name):
|
| return
|
| if len(method1.args.args) != len(refmethod.args.args):
|
| - self.add_message('arguments-differ', args=class_type, node=method1)
|
| + self.add_message('arguments-differ',
|
| + args=(class_type, method1.name),
|
| + node=method1)
|
| elif len(method1.args.defaults) < len(refmethod.args.defaults):
|
| - self.add_message('signature-differs', args=class_type, node=method1)
|
| + self.add_message('signature-differs',
|
| + args=(class_type, method1.name),
|
| + node=method1)
|
|
|
| def is_first_attr(self, node):
|
| """Check that attribute lookup name use first attribute variable name
|
|
|