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:
objectMetadata for a single function or method definition from the AST.
- Parameters:
name (str)
lineno (int)
is_async (bool) –
Trueforasync defdefinitions.decorators (list of str) – Plain names of all decorators (e.g.
["classmethod"]).is_overload (bool) –
Truewhenoverloadappears 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
Nonewhen absent.kwargs_forwarded_to (list of str) – Names of callables to which
**kwargsis forwarded in the body. Populated by the body scanner inASTHarvester._harvest_function(). Used byresolve_function_params()to expand variadic parameters into their concrete counterparts.args_forwarded_to (list of str) – Names of callables to which
*argsis 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 []
See also
Public API reference — overview of all public names.