@@ -599,7 +599,7 @@ function.
599
599
600
600
.. function :: signature(callable, *, follow_wrapped=True, globals=None, locals=None, eval_str=False)
601
601
602
- Return a :class: `Signature ` object for the given `` callable `` ::
602
+ Return a :class: `Signature ` object for the given * callable * ::
603
603
604
604
>>> from inspect import signature
605
605
>>> def foo(a, *, b:int, **kwargs):
@@ -625,29 +625,30 @@ function.
625
625
For objects defined in modules using stringized annotations
626
626
(``from __future__ import annotations ``), :func: `signature ` will
627
627
attempt to automatically un-stringize the annotations using
628
- :func: `inspect. get_annotations() `. The
629
- `` global ``, `` locals `` , and `` eval_str `` parameters are passed
630
- into :func: `inspect. get_annotations() ` when resolving the
631
- annotations; see the documentation for :func: `inspect. get_annotations() `
628
+ :func: `get_annotations `. The
629
+ * global *, * locals * , and * eval_str * parameters are passed
630
+ into :func: `get_annotations ` when resolving the
631
+ annotations; see the documentation for :func: `get_annotations `
632
632
for instructions on how to use these parameters.
633
633
634
634
Raises :exc: `ValueError ` if no signature can be provided, and
635
635
:exc: `TypeError ` if that type of object is not supported. Also,
636
- if the annotations are stringized, and `` eval_str `` is not false,
637
- the ``eval() `` call(s) to un-stringize the annotations could
638
- potentially raise any kind of exception.
636
+ if the annotations are stringized, and * eval_str * is not false,
637
+ the ``eval() `` call(s) to un-stringize the annotations in :func: ` get_annotations `
638
+ could potentially raise any kind of exception.
639
639
640
640
A slash(/) in the signature of a function denotes that the parameters prior
641
641
to it are positional-only. For more info, see
642
642
:ref: `the FAQ entry on positional-only parameters <faq-positional-only-arguments >`.
643
643
644
- .. versionadded :: 3.5
645
- ``follow_wrapped `` parameter. Pass ``False `` to get a signature of
646
- ``callable `` specifically (``callable.__wrapped__ `` will not be used to
644
+ .. versionchanged :: 3.5
645
+ The *follow_wrapped * parameter was added.
646
+ Pass ``False `` to get a signature of
647
+ *callable * specifically (``callable.__wrapped__ `` will not be used to
647
648
unwrap decorated callables.)
648
649
649
- .. versionadded :: 3.10
650
- `` globals ``, `` locals `` , and `` eval_str `` parameters.
650
+ .. versionchanged :: 3.10
651
+ The * globals *, * locals * , and * eval_str * parameters were added .
651
652
652
653
.. note ::
653
654
@@ -727,12 +728,10 @@ function.
727
728
>>> str(new_sig)
728
729
"(a, b) -> 'new return anno'"
729
730
730
- .. classmethod :: Signature.from_callable(obj, *, follow_wrapped=True, globalns =None, localns =None)
731
+ .. classmethod :: Signature.from_callable(obj, *, follow_wrapped=True, globals =None, locals =None, eval_str=False )
731
732
732
733
Return a :class: `Signature ` (or its subclass) object for a given callable
733
- ``obj ``. Pass ``follow_wrapped=False `` to get a signature of ``obj ``
734
- without unwrapping its ``__wrapped__ `` chain. ``globalns `` and
735
- ``localns `` will be used as the namespaces when resolving annotations.
734
+ *obj *.
736
735
737
736
This method simplifies subclassing of :class: `Signature `::
738
737
@@ -745,8 +744,8 @@ function.
745
744
746
745
.. versionadded :: 3.5
747
746
748
- .. versionadded :: 3.10
749
- `` globalns `` and `` localns `` parameters.
747
+ .. versionchanged :: 3.10
748
+ The * globals *, * locals *, and * eval_str * parameters were added .
750
749
751
750
752
751
.. class :: Parameter(name, kind, *, default=Parameter.empty, annotation=Parameter.empty)
0 commit comments