def annotate_function_with_types(f):
    if hasattr(f, '_orig_arg_names'):
        arg_names = f._orig_arg_names
    else:
        arg_names = f.__code__.co_varnames[0:f.__code__.co_argcount]
    argtypes = []
    for name in arg_names:
        arg_type = types.get(name, 'any')
        if (arg_type not in VALID_ARG_TYPES):
            raise ValueError(('Argument type %s is not valid, must be one of %s, for argument %s' % (arg_type, VALID_ARG_TYPES, name)))
        argtypes.append(arg_type)
    for n in types:
        if ((n not in arg_names) and (n != 'result')):
            raise ValueError(('Type specified for unknown argument ' + n))
    return_type = types.get('result', 'float')
    if (return_type not in VALID_RETURN_TYPES):
        raise ValueError(('Result type %s is not valid, must be one of %s' % (return_type, VALID_RETURN_TYPES)))
    f._arg_types = argtypes
    f._return_type = return_type
    f._orig_arg_names = arg_names
    f._annotation_attributes = (getattr(f, '_annotation_attributes', []) + ['_arg_types', '_return_type'])
    return f
def annotate_function_with_types(f):
    if hasattr(f, '_orig_arg_names'):
        arg_names = f._orig_arg_names
    else:
        arg_names = f.__code__.co_varnames[0:f.__code__.co_argcount]
    argtypes = []
    for name in arg_names:
        arg_type = types.get(name, 'any')
        if (arg_type not in VALID_ARG_TYPES):
            raise ValueError(('Argument type %s is not valid, must be one of %s, for argument %s' % (arg_type, VALID_ARG_TYPES, name)))
        argtypes.append(arg_type)
    for n in types:
        if ((n not in arg_names) and (n != 'result')):
            raise ValueError(('Type specified for unknown argument ' + n))
    return_type = types.get('result', 'float')
    if (return_type not in VALID_RETURN_TYPES):
        raise ValueError(('Result type %s is not valid, must be one of %s' % (return_type, VALID_RETURN_TYPES)))
    f._arg_types = argtypes
    f._return_type = return_type
    f._orig_arg_names = arg_names
    f._annotation_attributes = (getattr(f, '_annotation_attributes', []) + ['_arg_types', '_return_type'])
    return f