[issue23764] functools.wraps should be able to change function argspec as well

2015-03-25 Thread productivememberofsociety666
productivememberofsociety666 added the comment: def wrapper(func): return functools.wraps(func)(functools.partial(func)) ^ doesn't that just return something that is completely equivalent to func itself? Where do I put the actual wrapper functionality, i.e. code that is executed with each

[issue23764] functools.wraps should be able to change function argspec as well

2015-03-25 Thread Nick Coghlan
Nick Coghlan added the comment: Full example showing the functools.partial based implementation: >>> def wrapper(func): ... return functools.wraps(func)(functools.partial(func)) ... >>> def to_be_wrapped(x): ... pass ...

[issue23764] functools.wraps should be able to change function argspec as well

2015-03-25 Thread Nick Coghlan
Nick Coghlan added the comment: Backport proposal: https://github.com/aliles/funcsigs/issues/12 -- ___ Python tracker ___ ___ Python-b

[issue23764] functools.wraps should be able to change function argspec as well

2015-03-25 Thread Nick Coghlan
Nick Coghlan added the comment: Regarding the PyPI decorator module, the difference there is between using a "def f(*args, **kwargs)" wrapper (which requires following wrapper chains to read the signature correctly) and using functools.partial (which reports the correct surface signature direc

[issue23764] functools.wraps should be able to change function argspec as well

2015-03-25 Thread productivememberofsociety666
productivememberofsociety666 added the comment: You're probably right and it's next to impossible to implement what I want in a clean manner. I'll get back to that at the end, but first for completeness's sake two examples to illustrate what this issue is even about. import functools de

[issue23764] functools.wraps should be able to change function argspec as well

2015-03-25 Thread Nick Coghlan
Nick Coghlan added the comment: I double checked the current behaviour, and rediscovered something I had forgotten: when inspect.getargspec and inspect.getfullargspec were converted to be based on the inspect.signature machinery, we had to decide whether or not to follow wrapper chains to repo

[issue23764] functools.wraps should be able to change function argspec as well

2015-03-25 Thread R. David Murray
R. David Murray added the comment: I think you need to explain exactly what it is you are looking for, because it doesn't seem to me that you can change the argspec of a function. What is it that decorator is doing that is helpful? -- ___ Python tr

[issue23764] functools.wraps should be able to change function argspec as well

2015-03-25 Thread Nick Coghlan
Nick Coghlan added the comment: Correctly processing a function's signature involves following the __wrapped__ chains to get to the underlying callable (or to a callable that defines an explicitly modified __signature__ value). inspect.signature follows these chains automatically, and in 3.4+

[issue23764] functools.wraps should be able to change function argspec as well

2015-03-24 Thread productivememberofsociety666
productivememberofsociety666 added the comment: I'm not sure if I understand issue 15731 correctly, but isn't that one just about docstrings and signatures? These are both purely "cosmetic" and don't have an effect on calling behaviour, do they? This issue wouldn't be a duplicate then. ---

[issue23764] functools.wraps should be able to change function argspec as well

2015-03-24 Thread R. David Murray
R. David Murray added the comment: See also issue 15731 (this might be effectively a duplicate of that one, I'm not sure). I believe the idea of incorporating decorator into the stdlib has been brought up in the past. -- nosy: +r.david.murray ___ P

[issue23764] functools.wraps should be able to change function argspec as well

2015-03-24 Thread SilentGhost
Changes by SilentGhost : -- nosy: +ncoghlan, rhettinger versions: -Python 3.2, Python 3.3, Python 3.4, Python 3.6 ___ Python tracker ___

[issue23764] functools.wraps should be able to change function argspec as well

2015-03-24 Thread productivememberofsociety666
New submission from productivememberofsociety666: functools.wraps currently only changes the wrapped function's "superficial" attributes such as docstring or annotations. But it would be useful to be able to change the function's actual argspec as well so it matches up with the changed annotat