On this page
  1. inspect.Signature
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

inspect.Signature

Prev: inspect.Parameter | Up: inspect | Next: inspect.Traceback
Rel: inspect.ArgInfo, inspect.Arguments, inspect.Attribute, inspect.BlockFinder
Ref: docs.python.org — inspect.Signature
Tags: #public #python3 #stdlib #inspect


Import

import inspect
from inspect import Signature

Signature & Overview

inspect.Signature(parameters=None, *, return_annotation, __validate_parameters__=True)

A Signature object represents the overall signature of a function.

Methods & Attributes

Usage

import inspect

def add(a: int, b: int = 10) -> int:
    return a + b

sig = inspect.signature(add)
assert list(sig.parameters) == ["a", "b"]
assert sig.return_annotation is int

Gotchas

REPL Inspect

from inspect import Signature
help(Signature)

Linked from

Related notes