module documentation

this module contains a set of functions to create astroid trees from scratch (build_* functions) or from living object (object_build_* functions)

Class InspectBuilder class for building nodes from living object
Function attach_const_node create a Const node and register it in the locals of the given node with the specified name
Function attach_dummy_node create a dummy node and register it in the locals of the given node with the specified name
Function attach_import_node create a ImportFrom node and register it in the locals of the given node with the specified name
Function build_class Create and initialize an astroid ClassDef node.
Function build_from_import create and initialize an astroid ImportFrom import statement
Function build_function create and initialize an astroid FunctionDef node
Function build_module create and initialize an astroid Module node
Function object_build_class create astroid for a living class object
Function object_build_datadescriptor create astroid for a living data descriptor object
Function object_build_function create astroid for a living function object
Function object_build_methoddescriptor create astroid for a living method descriptor object
Function register_arguments add given arguments to local
Constant TYPE_ELLIPSIS Undocumented
Constant TYPE_NONE Undocumented
Constant TYPE_NOTIMPLEMENTED Undocumented
Variable logger Undocumented
Function _add_dunder_class Add a __class__ member to the given func node, if we can determine it.
Function _astroid_bootstrapping astroid bootstrapping the builtins module
Function _attach_local_node Undocumented
Function _base_class_object_build create astroid for a living class object, with a given set of base names (e.g. ancestors)
Function _build_from_function Undocumented
Function _get_args_info_from_callable Returns args, posonlyargs, defaults, kwonlyargs.
Function _safe_has_attribute Required because unexpected RunTimeError can be raised.
Function _set_proxied Undocumented
Constant _BUILTINS Undocumented
Constant _CONST_PROXY Undocumented
Constant _CONSTANTS Undocumented
Type Alias _FunctionTypes Undocumented
def attach_const_node(node, name: str, value): (source)

create a Const node and register it in the locals of the given node with the specified name

def attach_dummy_node(node, name: str, runtime_object=_EMPTY_OBJECT_MARKER): (source)

create a dummy node and register it in the locals of the given node with the specified name

def attach_import_node(node, modname: str, membername: str): (source)

create a ImportFrom node and register it in the locals of the given node with the specified name

def build_class(name: str, basenames: Iterable[str] = (), doc: str|None = None) -> nodes.ClassDef: (source)

Create and initialize an astroid ClassDef node.

def build_from_import(fromname: str, names: list[str]) -> nodes.ImportFrom: (source)

create and initialize an astroid ImportFrom import statement

def build_function(name: str, args: list[str]|None = None, posonlyargs: list[str]|None = None, defaults: list[Any]|None = None, doc: str|None = None, kwonlyargs: list[str]|None = None, kwonlydefaults: list[Any]|None = None) -> nodes.FunctionDef: (source)

create and initialize an astroid FunctionDef node

def build_module(name: str, doc: str|None = None) -> nodes.Module: (source)

create and initialize an astroid Module node

def object_build_class(node: nodes.Module|nodes.ClassDef, member: type, localname: str) -> nodes.ClassDef: (source)

create astroid for a living class object

def object_build_datadescriptor(node: nodes.Module|nodes.ClassDef, member: type, name: str) -> nodes.ClassDef: (source)

create astroid for a living data descriptor object

def object_build_function(node: nodes.Module|nodes.ClassDef, member: _FunctionTypes, localname: str): (source)

create astroid for a living function object

def object_build_methoddescriptor(node: nodes.Module|nodes.ClassDef, member: _FunctionTypes, localname: str): (source)

create astroid for a living method descriptor object

def register_arguments(func: nodes.FunctionDef, args: list|None = None): (source)

add given arguments to local args is a list that may contains nested lists (i.e. def func(a, (b, c, d)): ...)

TYPE_ELLIPSIS = (source)

Undocumented

Value
type(...)
TYPE_NONE = (source)

Undocumented

Value
type(None)
TYPE_NOTIMPLEMENTED = (source)

Undocumented

Value
type(NotImplemented)

Undocumented

def _add_dunder_class(func, member): (source)

Add a __class__ member to the given func node, if we can determine it.

def _astroid_bootstrapping(): (source)

astroid bootstrapping the builtins module

def _attach_local_node(parent, node, name: str): (source)

Undocumented

def _base_class_object_build(node: nodes.Module|nodes.ClassDef, member: type, basenames: list[str], name: str|None = None, localname: str|None = None) -> nodes.ClassDef: (source)

create astroid for a living class object, with a given set of base names (e.g. ancestors)

def _build_from_function(node: nodes.Module|nodes.ClassDef, name: str, member: _FunctionTypes, module: types.ModuleType): (source)

Undocumented

def _get_args_info_from_callable(member: _FunctionTypes) -> tuple[list[str], list[str], list[Any], list[str], list[Any]]: (source)

Returns args, posonlyargs, defaults, kwonlyargs. :note: currently ignores the return annotation.

def _safe_has_attribute(obj, member: str) -> bool: (source)

Required because unexpected RunTimeError can be raised. See https://github.com/PyCQA/astroid/issues/1958

def _set_proxied(const) -> nodes.ClassDef: (source)

Undocumented

_BUILTINS = (source)

Undocumented

Value
vars(builtins)

Undocumented

Value
{}
_CONSTANTS = (source)

Undocumented

Value
tuple(node_classes.CONST_CLS)