FunctionInfo

class FunctionInfo(name: str, lineno: int, is_async: bool = False, decorators: list[str] = <factory>, is_overload: bool = False, raw_arg_annotations: dict[str, str]=<factory>, raw_return_annotation: str | None = None, kwargs_forwarded_to: list[str] = <factory>, args_forwarded_to: list[str] = <factory>)[source]

Bases: object

Metadata for a single function or method definition from the AST.

Parameters:
  • name (str)

  • lineno (int)

  • is_async (bool) – True for async def definitions.

  • decorators (list of str) – Plain names of all decorators (e.g. ["classmethod"]).

  • is_overload (bool) – True when overload appears in decorators.

  • raw_arg_annotations (dict) – Maps parameter name → unparsed annotation string for every annotated parameter. Variadic names are prefixed: "*args", "**kwargs".

  • raw_return_annotation (str or None) – Unparsed return-annotation string, or None when absent.

  • kwargs_forwarded_to (list of str) – Names of callables to which **kwargs is forwarded in the body. Populated by the body scanner in ASTHarvester._harvest_function(). Used by resolve_function_params() to expand variadic parameters into their concrete counterparts.

  • args_forwarded_to (list of str) – Names of callables to which *args is forwarded in the body. Same purpose as kwargs_forwarded_to for positional variadics.

Examples

>>> info = FunctionInfo(name="greet", lineno=5, is_async=False)
>>> info.is_overload
False
>>> info.kwargs_forwarded_to
[]
name: str
lineno: int
is_async: bool = False
decorators: list[str]
is_overload: bool = False
raw_arg_annotations: dict[str, str]
raw_return_annotation: str | None = None
kwargs_forwarded_to: list[str]
args_forwarded_to: list[str]
__init__(name: str, lineno: int, is_async: bool = False, decorators: list[str] = <factory>, is_overload: bool = False, raw_arg_annotations: dict[str, str]=<factory>, raw_return_annotation: str | None = None, kwargs_forwarded_to: list[str] = <factory>, args_forwarded_to: list[str] = <factory>) None

See also

Public API reference — overview of all public names.