E0222

Message

Missing method %r from %s interface

Description

Used when a method declared in an interface is missing from a class implementing this interface.

Explanation

Explanation
This message appears when you have a class A that implements an interface I and that interface has a method m() that was not overwritten in the class A.

So, in other words, you have to define and implement your A.m() method declared in I.m() (interfaces are contracts expected to be fulfilled)

Example of code that won't pass this check:

interface Iterable:
            "A set that can be iterated over its elements"

            def next():
                "this method returns the next element"
                 raise NotImplementedError('users must define __str__ to use this base class')
            def hasNext();
                "This method check if the set is not empty"
                 raise NotImplementedError('users must define __str__ to use this base class')

class Car (Iterable):
            num_wheels = 4
            def hasNext():
                 return num_wheels>0
            .... #other methods but not the next() method

If you like to learn more about Python interfaces: [ https://www.python.org/dev/peps/pep-0245/]


Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License