Please use __annotations__ instead of inspect.signature


#1

With 4.x and 5.x it’s not possible to enclose the handler to handle exceptions and a custom and always present response object.

def decorator(func):
    def wrapper(*args, **kwargs):
        try:
            ret = func(*args, **kwargs)
            return success(ret)
        except Exception as exc:
            logger.exception()
            return error(exc)   
     return wrapper

#2

I assume you’d need to use ‘functools.wraps’ right?


#3

Rigth, but inspect inspects the code object wich is a unannotated args and kwargs, i.e. don’t know about any stuff done by wraps. But wraps copy annotations, so this change would be appreciated.


#4

Ditto, I am trying to write a decorator that injects a http.Cookie annotation into a view but cannot get the dependency injector to recognize the added kwarg


Apistar-contrib: Extra batteries for API Star 0.4+ (Session and CSRF)