hugapi / hug

Embrace the APIs of the future. Hug aims to make developing APIs as simple as possible, but no simpler.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: __call__() missing 1 required positional argument: 'context'

ptitpoulpe opened this issue · comments

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)