[Python-checkins] cpython: inspect.docs: Document constructors for Signature & Parameter #20442

yury.selivanov python-checkins at python.org
Thu Jan 30 06:12:30 CET 2014


http://hg.python.org/cpython/rev/0a3201aab2b8
changeset:   88832:0a3201aab2b8
user:        Yury Selivanov <yselivanov at sprymix.com>
date:        Thu Jan 30 00:10:54 2014 -0500
summary:
  inspect.docs: Document constructors for Signature & Parameter #20442

files:
  Doc/library/inspect.rst |  13 +++++++++++--
  1 files changed, 11 insertions(+), 2 deletions(-)


diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -444,12 +444,21 @@
       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 @@
          "(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.

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list