GrahamDumpleton / wrapt

A Python module for decorators, wrappers and monkey patching.
BSD 2-Clause "Simplified" License
2.03k stars 231 forks source link

Signature Changing Decorators issue #232

Open subsurfaceiodev opened 1 year ago

subsurfaceiodev commented 1 year ago

Hey there! First of all, thanks for this wonderful package. We are currently facing an issue when dealing with "Signature Changing Decorators" functionality,

Currently, wrapt allows you to change wrapped function's signature via the argspec_factory adapter and it works. The question is, how can you send current args / kwargs to this argspec_factory adapter so you can change the function´s signature depending on the value(s) of current args / kwargs. So, for example, if user gives input "consider_port_is_present" = False, then we could change wrapped function's signature depending on that value (e.g. adding "port" argument to argspec only if consider_port_is_present is True).

GrahamDumpleton commented 1 year ago

Can you show any rough code you have now? I don't need the full body of your decorator, but do need to see how using argspec_factory now and whether you are creating a decorator which takes arguments. If not creating a decorator with arguments I don't understand where consider_port_is_present argument is being supplied.