diff options
author | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-05-05 12:05:09 +0300 |
---|---|---|
committer | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-05-05 12:05:09 +0300 |
commit | 68fee0184aa4aa45f64f287b44ab940e7d3fb730 (patch) | |
tree | 2c46f1218647fa41d953ccb7c81dd955d524a24f /pylint/checkers/classes.py | |
parent | ea168a926e88406d07dbc8e6a388faab5903051c (diff) | |
download | pylint-68fee0184aa4aa45f64f287b44ab940e7d3fb730.tar.gz |
Remove the rest of interface checks.
The removed checks are interface-is-not-class,
missing-interface-method, unresolved-interface. The reason is that
its better to start recommending ABCs instead of the old Zope era
of interfaces.
Diffstat (limited to 'pylint/checkers/classes.py')
-rw-r--r-- | pylint/checkers/classes.py | 78 |
1 files changed, 4 insertions, 74 deletions
diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py index f957335..007cb42 100644 --- a/pylint/checkers/classes.py +++ b/pylint/checkers/classes.py @@ -171,15 +171,6 @@ MSGS = { 'Used when a method doesn\'t use its bound instance, and so could ' 'be written as a function.' ), - - 'E0221': ('Interface resolved to %s is not a class', - 'interface-is-not-class', - 'Used when a class claims to implement an interface which is not ' - 'a class.'), - 'E0222': ('Missing method %r from %s interface', - '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 %r method', 'arguments-differ', 'Used when a method has a different number of arguments than in ' @@ -193,12 +184,6 @@ MSGS = { 'Used when an abstract method (i.e. raise NotImplementedError) is ' 'not overridden in concrete class.' ), - 'F0220': ('failed to resolve interfaces implemented by %s (%s)', - 'unresolved-interface', - 'Used when a Pylint as failed to find interfaces implemented by ' - ' a class'), - - 'W0231': ('__init__ method from base class %r is not called', 'super-init-not-called', 'Used when an ancestor class method has an __init__ method ' @@ -253,7 +238,6 @@ class ClassChecker(BaseChecker): * overridden methods signature * access only to existent members via self * attributes not defined in the __init__ method - * supported interfaces implementation * unreachable code """ @@ -321,12 +305,11 @@ a metaclass class method.'} self._meth_could_be_func = None def visit_class(self, node): - """init visit variable _accessed and check interfaces + """init visit variable _accessed """ self._accessed.append(defaultdict(list)) self._check_bases_classes(node) - self._check_interfaces(node) - # if not an interface, exception, metaclass + # if not an exception or a metaclass if node.type == 'class': try: node.local_attr('__init__') @@ -558,8 +541,7 @@ a metaclass class method.'} """on method node, check if this method couldn't be a function ignore class, static and abstract methods, initializer, - methods overridden from a parent class and any - kind of method defined in an interface for this warning + methods overridden from a parent class. """ if node.is_method(): if node.args.args is not None: @@ -571,8 +553,7 @@ a metaclass class method.'} and not node.name in PYMETHODS and not (node.is_abstract() or overrides_a_method(class_node, node.name) or - decorated_with_property(node)) - and class_node.type != 'interface'): + decorated_with_property(node))): self.add_message('no-self-use', node=node) def visit_getattr(self, node): @@ -843,55 +824,6 @@ a metaclass class method.'} 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 - interfaces - """ - e0221_hack = [False] - def iface_handler(obj): - """filter interface objects, it should be classes""" - if not isinstance(obj, astroid.Class): - e0221_hack[0] = True - self.add_message('interface-is-not-class', node=node, - args=(obj.as_string(),)) - return False - return True - ignore_iface_methods = self.config.ignore_iface_methods - try: - for iface in node.interfaces(handler_func=iface_handler): - for imethod in iface.methods(): - name = imethod.name - if name.startswith('_') or name in ignore_iface_methods: - # don't check method beginning with an underscore, - # usually belonging to the interface implementation - continue - # get class method astroid - try: - method = node_method(node, name) - except astroid.NotFoundError: - self.add_message('missing-interface-method', - args=(name, iface.name), - node=node) - continue - # ignore inherited methods - if method.parent.frame() is not node: - continue - # check signature - self._check_signature(method, imethod, - '%s interface' % iface.name) - except astroid.InferenceError: - if e0221_hack[0]: - return - implements = Instance(node).getattr('__implements__')[0] - assignment = implements.parent - assert isinstance(assignment, astroid.Assign) - # assignment.expr can be a Name or a Tuple or whatever. - # Use as_string() for the message - # FIXME: in case of multiple interfaces, find which one could not - # be resolved - self.add_message('unresolved-interface', node=implements, - args=(node.name, assignment.value.as_string())) - def _check_init(self, node): """check that the __init__ method call super or ancestors'__init__ method @@ -943,8 +875,6 @@ a metaclass class method.'} def _check_signature(self, method1, refmethod, class_type): """check that the signature of the two given methods match - - class_type is in 'class', 'interface' """ if not (isinstance(method1, astroid.Function) and isinstance(refmethod, astroid.Function)): |