Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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