inspect.stack()

inspect.stack(context=1) Return a list of frame records for the caller’s stack. The first entry in the returned list represents the caller; the last entry represents the outermost call on the stack. Changed in version 3.5: A list of named tuples FrameInfo(frame, filename, lineno, function, code_context, index) is returned.

inspect.Signature.return_annotation

return_annotation The “return” annotation for the callable. If the callable has no “return” annotation, this attribute is set to Signature.empty.

inspect.Signature.replace()

replace(*[, parameters][, return_annotation]) 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. >>> def test(a, b): ... pass >>> sig = signature(test) >>> new_sig = sig.replace(return_annotation="new return anno") >>&g

inspect.Signature.parameters

parameters An ordered mapping of parameters’ names to the corresponding Parameter objects.

inspect.Signature.from_callable()

classmethod from_callable(obj, *, follow_wrapped=True) Return a Signature (or its subclass) object for a given callable obj. Pass follow_wrapped=False to get a signature of obj without unwrapping its __wrapped__ chain. This method simplifies subclassing of Signature: class MySignature(Signature): pass sig = MySignature.from_callable(min) assert isinstance(sig, MySignature) New in version 3.5.

inspect.Signature.empty

empty A special class-level marker to specify absence of a return annotation.

inspect.Signature.bind_partial()

bind_partial(*args, **kwargs) Works the same way as Signature.bind(), but allows the omission of some required arguments (mimics functools.partial() behavior.) Returns BoundArguments, or raises a TypeError if the passed arguments do not match the signature.

inspect.Signature.bind()

bind(*args, **kwargs) Create a mapping from positional and keyword arguments to parameters. Returns BoundArguments if *args and **kwargs match the signature, or raises a TypeError.

inspect.signature()

inspect.signature(callable, *, follow_wrapped=True) Return a Signature object for the given callable: >>> from inspect import signature >>> def foo(a, *, b:int, **kwargs): ... pass >>> sig = signature(foo) >>> str(sig) '(a, *, b:int, **kwargs)' >>> str(sig.parameters['b']) 'b:int' >>> sig.parameters['b'].annotation <class 'int'> Accepts a wide range of python callables, from plain functions and classes to functools.partial(

inspect.Parameter.replace()

replace(*[, name][, kind][, default][, annotation]) Create a new Parameter instance based on the instance replaced was invoked on. To override a Parameter attribute, pass the corresponding argument. To remove a default value or/and an annotation from a Parameter, pass Parameter.empty. >>> from inspect import Parameter >>> param = Parameter('foo', Parameter.KEYWORD_ONLY, default=42) >>> str(param) 'foo=42' >>> str(param.replace()) # Will create a shallow c