hug
hug copied to clipboard
TypeError: __call__() missing 1 required positional argument: 'context'
If a validator handler raise a TypeError
hug catch it believing (here) that’s is an expected error unexpected keyword argument "context"
A solution is to use replace initialize_handler
code with something like that:
import inspect
def initialize_handler(handler, value, context):
if "context" in inspect.signature(handler).parameters: # It's better to ask for permission than for forgiveness
return handler(value, context=context)
else:
return handler(value)