#!/usr/local/cpython-3.6/bin/python3 """Rather poor example of using pylint interfaces.""" class Interface: # pylint: disable=too-few-public-methods """Just for declaring a class an interface to pylint.""" pass class Polygon: """Polygon class.""" def num_sides(self): """Return number of sides this polygon has.""" pass def color(self): """Return color of this polygon.""" pass def perimeter(self): """Return the perimeter of this polygon.""" pass class RedSquare: """ A class for a red square. In real life, this would probably be an instance, not a class. """ __implements__ = (Polygon, ) @staticmethod def num_sides(): """We have 4 sides.""" return 4 @staticmethod def color(): """We are red.""" return 'Red' @staticmethod def perimeter(): """Return the perimeter of the square.""" return 4 class BlueTriangle: """ A class for a blue triangle. In real life, this would probably be an instance, not a class. """ __implements__ = (Polygon, ) @staticmethod def num_sides(): """We have 3 sides.""" return 3 @staticmethod def color(): """We are blue.""" return 'Blue' # Note that we have no perimeter method - and yet pylint doesn't complain :-S def main(): """Main function.""" list_ = [RedSquare(), BlueTriangle()] for element in list_: print(element.num_sides()) print(element.color()) # Pylint 1.7.1 incorrectly thinks that perimeter is part of BlueTriangle print(element.perimeter()) main()