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):
return_value = fn(*args, **kwargs)
if not is_type(return_value, return_type):
if coerce_type:
try:
return_value = return_type(return_value)
except Exception:
raise ReturnTypeError(return_type, return_value)
else:
raise ReturnTypeError(return_type, return_value)
return return_value
return typed_fn
def typed_fn(fn, *args, **kwargs):
return_value = fn(*args, **kwargs)
if not is_type(return_value, return_type):
if coerce_type:
try:
return_value = return_type(return_value)
except Exception:
raise ReturnTypeError(return_type, return_value)
else:
raise ReturnTypeError(return_type, return_value)
return return_value
return typed_fn