A function decorator which coerces argument values to the annotated types.
    This decorator is implicitly applied to command and option functions.
    Explicitly wrapping your functions with it allows more fine-grained
    configuration and the usage of annotations in Python 2. Applying this
    decorator multiple times will raise a :py:exc:`RuntimeError`.

    :param from_defaults: Infer the type of arguments by their default value.
    :param kwargs: Python 2 doesn't have function annotations, so you can
        also pass types here as keyword arguments.

def annotations(from_defaults=True, **kwargs):
    """
    A function decorator which coerces argument values to the annotated types.
    This decorator is implicitly applied to command and option functions.
    Explicitly wrapping your functions with it allows more fine-grained
    configuration and the usage of annotations in Python 2. Applying this
    decorator multiple times will raise a :py:exc:`RuntimeError`.

    :param from_defaults: Infer the type of arguments by their default value.
    :param kwargs: Python 2 doesn't have function annotations, so you can
        also pass types here as keyword arguments.
    """

    def decorator(func):
        func = set_annotations(**kwargs)(func)
        if from_defaults:
            func = infer_from_defaults(func)
        func = resolve_shortcuts(func)
        func = with_annotations(func)
        return func

    return decorator