summaryrefslogtreecommitdiffstats
path: root/Doc/library/inspect.rst
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2014-01-30 05:10:54 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2014-01-30 05:10:54 (GMT)
commit783568980a6494070f75de5dc8e80631b02d79af (patch)
tree149be3eefd8bca0d784d0517c3093cd4cf0d8f59 /Doc/library/inspect.rst
parent1ad5afc050778759dcbd6e338d9bd94ae2211a43 (diff)
downloadcpython-783568980a6494070f75de5dc8e80631b02d79af.zip
cpython-783568980a6494070f75de5dc8e80631b02d79af.tar.gz
cpython-783568980a6494070f75de5dc8e80631b02d79af.tar.bz2
inspect.docs: Document constructors for Signature & Parameter #20442
Diffstat (limited to 'Doc/library/inspect.rst')
-rw-r--r--Doc/library/inspect.rst13
1 files changed, 11 insertions, 2 deletions
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
index 91d8831..492762e 100644
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -444,12 +444,21 @@ function.
no metadata about their arguments.
-.. class:: Signature
+.. class:: Signature(parameters=None, \*, return_annotation=Signature.empty)
A Signature object represents the call signature of a function and its return
annotation. For each parameter accepted by the function it stores a
:class:`Parameter` object in its :attr:`parameters` collection.
+ The optional *parameters* argument is a sequence of :class:`Parameter`
+ objects, which is validated to check that there are no parameters with
+ duplicate names, and that the parameters are in the right order, i.e.
+ positional-only first, then positional-or-keyword, and that parameters with
+ defaults follow parameters without defaults.
+
+ The optional *return_annotation* argument, can be an arbitrary Python object,
+ is the "return" annotation of the callable.
+
Signature objects are *immutable*. Use :meth:`Signature.replace` to make a
modified copy.
@@ -498,7 +507,7 @@ function.
"(a, b) -> 'new return anno'"
-.. class:: Parameter
+.. class:: Parameter(name, kind, \*, default=Parameter.empty, annotation=Parameter.empty)
Parameter objects are *immutable*. Instead of modifying a Parameter object,
you can use :meth:`Parameter.replace` to create a modified copy.