python - Tracking decorator not passing arguments -


i'm working on alexa skill flask-ask. want log intent calls , arguments, , since intents conveniently annotated ask.intent decorator, figured either change code of flask-ask logging in code of decorator, or decorate myself, preferable avoid problems patching library when deploying production.

i've built solution below, problem *args , **kwargs empty, instead of being passed on over voted solution this issue.

def tracked_intent(intent_name, mapping={}, convert={}, default={}):     def decorator(f):         @ask.intent(intent_name, mapping, convert, default)         def new_func(*args, **kwargs):             print('got intent {} arguments {} , {}'.format(intent_name, str(args), str(kwargs)))             return f(*args, **kwargs)         new_func.__name__ = f.__name__         return new_func     return decorator 

thus, when have intent call requires argument, typeerror: function() missing 2 required positional arguments: 'arg1' , 'arg2'

how can fix decorator "extend" ask.intent decorator while correctly forwarding function arguments?


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -