@@ -620,7 +620,7 @@ function.
620
620
621
621
.. function :: signature(callable, *, follow_wrapped=True, globals=None, locals=None, eval_str=False)
622
622
623
- Return a :class: `Signature ` object for the given `` callable `` ::
623
+ Return a :class: `Signature ` object for the given * callable * ::
624
624
625
625
>>> from inspect import signature
626
626
>>> def foo(a, *, b:int, **kwargs):
@@ -646,29 +646,30 @@ function.
646
646
For objects defined in modules using stringized annotations
647
647
(``from __future__ import annotations ``), :func: `signature ` will
648
648
attempt to automatically un-stringize the annotations using
649
- :func: `inspect. get_annotations() `. The
650
- `` global ``, `` locals `` , and `` eval_str `` parameters are passed
651
- into :func: `inspect. get_annotations() ` when resolving the
652
- annotations; see the documentation for :func: `inspect. get_annotations() `
649
+ :func: `get_annotations `. The
650
+ * global *, * locals * , and * eval_str * parameters are passed
651
+ into :func: `get_annotations ` when resolving the
652
+ annotations; see the documentation for :func: `get_annotations `
653
653
for instructions on how to use these parameters.
654
654
655
655
Raises :exc: `ValueError ` if no signature can be provided, and
656
656
:exc: `TypeError ` if that type of object is not supported. Also,
657
- if the annotations are stringized, and `` eval_str `` is not false,
658
- the ``eval() `` call(s) to un-stringize the annotations could
659
- potentially raise any kind of exception.
657
+ if the annotations are stringized, and * eval_str * is not false,
658
+ the ``eval() `` call(s) to un-stringize the annotations in :func: ` get_annotations `
659
+ could potentially raise any kind of exception.
660
660
661
661
A slash(/) in the signature of a function denotes that the parameters prior
662
662
to it are positional-only. For more info, see
663
663
:ref: `the FAQ entry on positional-only parameters <faq-positional-only-arguments >`.
664
664
665
- .. versionadded :: 3.5
666
- ``follow_wrapped `` parameter. Pass ``False `` to get a signature of
667
- ``callable `` specifically (``callable.__wrapped__ `` will not be used to
665
+ .. versionchanged :: 3.5
666
+ The *follow_wrapped * parameter was added.
667
+ Pass ``False `` to get a signature of
668
+ *callable * specifically (``callable.__wrapped__ `` will not be used to
668
669
unwrap decorated callables.)
669
670
670
- .. versionadded :: 3.10
671
- `` globals ``, `` locals `` , and `` eval_str `` parameters.
671
+ .. versionchanged :: 3.10
672
+ The * globals *, * locals * , and * eval_str * parameters were added .
672
673
673
674
.. note ::
674
675
@@ -752,12 +753,10 @@ function.
752
753
Signature objects are also supported by generic function
753
754
:func: `copy.replace `.
754
755
755
- .. classmethod :: Signature.from_callable(obj, *, follow_wrapped=True, globalns =None, localns =None)
756
+ .. classmethod :: Signature.from_callable(obj, *, follow_wrapped=True, globals =None, locals =None, eval_str=False )
756
757
757
758
Return a :class: `Signature ` (or its subclass) object for a given callable
758
- ``obj ``. Pass ``follow_wrapped=False `` to get a signature of ``obj ``
759
- without unwrapping its ``__wrapped__ `` chain. ``globalns `` and
760
- ``localns `` will be used as the namespaces when resolving annotations.
759
+ *obj *.
761
760
762
761
This method simplifies subclassing of :class: `Signature `::
763
762
@@ -770,8 +769,8 @@ function.
770
769
771
770
.. versionadded :: 3.5
772
771
773
- .. versionadded :: 3.10
774
- `` globalns `` and `` localns `` parameters.
772
+ .. versionchanged :: 3.10
773
+ The * globals *, * locals *, and * eval_str * parameters were added .
775
774
776
775
777
776
.. class :: Parameter(name, kind, *, default=Parameter.empty, annotation=Parameter.empty)
0 commit comments