Please use __annotations__ instead of inspect.signature


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):
            ret = func(*args, **kwargs)
            return success(ret)
        except Exception as exc:
            return error(exc)   
     return wrapper


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


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.


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)