Issue 20691: Add follow_wrapped arg to inspect.signature/from_callable.

This commit is contained in:
Yury Selivanov 2015-05-20 14:30:08 -04:00
parent 1f507a8140
commit bcd4fc161a
5 changed files with 36 additions and 10 deletions

View file

@ -2664,9 +2664,10 @@ class Signature:
return _signature_from_builtin(cls, func)
@classmethod
def from_callable(cls, obj):
def from_callable(cls, obj, *, follow_wrapped=True):
"""Constructs Signature for the given callable object."""
return _signature_from_callable(obj, sigcls=cls)
return _signature_from_callable(obj, sigcls=cls,
follow_wrapper_chains=follow_wrapped)
@property
def parameters(self):
@ -2915,9 +2916,9 @@ class Signature:
return rendered
def signature(obj):
def signature(obj, *, follow_wrapped=True):
"""Get a signature object for the passed callable."""
return Signature.from_callable(obj)
return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
def _main():