How to use the runtype.__init__.InputTypeError function in runtype

To help you get started, we’ve selected a few runtype examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github madisonmay / Runtype / runtype / __init__.py View on Github external
def typed_fn(fn, *args, **kwargs):
        arguments = getcallargs(fn, *args, **kwargs)
        for name, value in arguments.iteritems():
            if name in type_info and not is_type(value, type_info[name]):
                if coerce_type:
                    try:
                        arguments[name] = type_info[name](value)
                    except Exception:
                        raise InputTypeError(name, value, type_info[name])
                else:
                    raise InputTypeError(name, value, type_info[name])
        return fn(**arguments)
    return typed_fn