skoot.decorators.overrides

skoot.decorators.overrides(interface_class)[source][source]

Decorator for methods that override super methods.

This decorator provides runtime validation that the method is, in fact, inherited from the superclass. If not, will raise an AssertionError.

Parameters:

interface_class : type

The class/type from which the specified method is inherited. If the method does not exist in the specified type, a RuntimeError will be raised.

Examples

The following is valid use:

>>> class A(object):
...     def a(self):
...         return 1
>>>
>>> class B(A):
...     @overrides(A)
...     def a(self):
...         return 2
...
...     def b(self):
...         return 0

The following would be an invalid overrides statement, since A does not have a b method to override.

>>> class C(B): 
...     @overrides(A) # should override B, not A
...     def b(self):
...         return 1
Traceback (most recent call last):
AssertionError: A.b must override a super method!