diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2014-01-30 05:12:02 (GMT) |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2014-01-30 05:12:02 (GMT) |
commit | 224c9c1f49d5746a7f0004829b72c14b959a0e44 (patch) | |
tree | 0a6dc296d296af0ed7c5e8c371be8ec5a884c25e /Doc | |
parent | bb08b365c03d1869ac457ba958c6ed13fcd8d461 (diff) | |
download | cpython-224c9c1f49d5746a7f0004829b72c14b959a0e44.zip cpython-224c9c1f49d5746a7f0004829b72c14b959a0e44.tar.gz cpython-224c9c1f49d5746a7f0004829b72c14b959a0e44.tar.bz2 |
inspect.docs: Document constructors for Signature & Parameter #20442
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/inspect.rst | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst index 7612544..d4cf905 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -435,12 +435,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. @@ -489,7 +498,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. |