def annotations(**kwargs):
    """Add Python 3 style __annotations__ to a Python 2 function.

    The return annotation should be specified via the 'returns' keyword
    argument to be syntactically valid.
    """
    def wrapper(func):
        if 'returns' in kwargs:
            kwargs['return'] = kwargs.pop('returns')
        func.__annotations__ = kwargs
        return func
    return wrapper