Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(17806)

Unified Diff: Doc/library/inspect.rst

Issue 20691: inspect.signature: Consider exposing 'follow_wrapper_chains' option in public API
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Lib/inspect.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Doc/library/inspect.rst Tue May 19 21:06:04 2015 +0200
+++ b/Doc/library/inspect.rst Tue May 19 17:17:09 2015 -0400
@@ -431,7 +431,7 @@
return annotation. To retrieve a Signature object, use the :func:`signature`
function.
-.. function:: signature(callable)
+.. function:: signature(callable, \*, follow_wrapped=True)
Return a :class:`Signature` object for the given ``callable``::
@@ -456,6 +456,11 @@
Raises :exc:`ValueError` if no signature can be provided, and
:exc:`TypeError` if that type of object is not supported.
+ .. versionadded:: 3.5
+ ``follow_wrapped`` parameter. Pass ``False`` to get a signature of
+ ``callable`` specifically (``callable.__wrapped__`` will not be used to
+ unwrap decorated callables.)
+
.. note::
Some callables may not be introspectable in certain implementations of
@@ -528,12 +533,13 @@
>>> str(new_sig)
"(a, b) -> 'new return anno'"
- .. classmethod:: Signature.from_callable(obj)
+ .. classmethod:: Signature.from_callable(obj, \*, follow_wrapped=True)
Return a :class:`Signature` (or its subclass) object for a given callable
- ``obj``. This method simplifies subclassing of :class:`Signature`:
+ ``obj``. Pass ``follow_wrapped=False`` to get a signature of ``obj``
+ without unwrapping its ``__wrapped__`` chain.
- ::
+ This method simplifies subclassing of :class:`Signature`::
class MySignature(Signature):
pass
« no previous file with comments | « no previous file | Lib/inspect.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+