Returns a set of :term:`interfaces <interface>` declared as implemented by
    class `cls`.

def get_implemented_interfaces(cls):
    """
    Returns a set of :term:`interfaces <interface>` declared as implemented by
    class `cls`.
    """
    if hasattr(cls, '__interfaces__'):
        return cls.__interfaces__
    return six.moves.reduce(
        lambda x, y: x.union(y),
        map(
            get_implemented_interfaces,
            inspect.getmro(cls)[1:]
        ),
        set()
    )