ID EN
Inspect

replace

Python 3.11

Create a new Signature instance based on the instance replace() was invoked on. It is possible to pass different parameters and/or return_annotation to override the corresponding properties of the base signature. To remove return_annotation from the copied Signature, pass in Signature.empty.

Syntax

PYTHON
replace(*[, parameters][, return_annotation])

Examples

Example 1
PYTHON
>>> def test(a, b):
...     pass
>>> sig = signature(test)
>>> new_sig = sig.replace(return_annotation="new return anno")
>>> str(new_sig)
"(a, b) -> 'new return anno'"

See Also

Signature replace() Signature.empty