class documentation

class AstroidManager: (source)

View In Hierarchy

Responsible to build astroid from files or modules. Use the Borg (singleton) pattern.

Method __init__ Undocumented
Method ast_from_class Get astroid for the given class.
Method ast_from_file Given a module name, return the astroid object.
Method ast_from_module Given an imported module, return the astroid object.
Method ast_from_module_name Given a module name, return the astroid object.
Method ast_from_string Given some source code as a string, return its corresponding astroid object.
Method bootstrap Bootstrap the required AST modules needed for the manager to work.
Method cache_module Cache a module if no module with the same name is known yet.
Method clear_cache Clear the underlying caches, bootstrap the builtins module and re-register transforms.
Method file_from_module_name Undocumented
Method infer_ast_from_something Infer astroid for the given class.
Method register_failed_import_hook Registers a hook to resolve imports that cannot be found otherwise.
Method visit_transforms Visit the transforms and apply them to the given *node*.
Method zip_import_data Undocumented
Class Variable brain Undocumented
Class Variable max_inferable_values Undocumented
Class Variable name Undocumented
Instance Variable always_load_extensions Undocumented
Instance Variable astroid_cache Undocumented
Instance Variable extension_package_whitelist Undocumented
Instance Variable optimize_ast Undocumented
Property builtins_module Undocumented
Property register_transform Undocumented
Property unregister_transform Undocumented
Method _build_namespace_module Undocumented
Method _build_stub_module Undocumented
Method _can_load_extension Undocumented
Instance Variable _failed_import_hooks Undocumented
Instance Variable _mod_file_cache Undocumented
Instance Variable _transform Undocumented
def __init__(self): (source)

Undocumented

def ast_from_class(self, klass: type, modname: str|None = None) -> nodes.ClassDef: (source)

Get astroid for the given class.

def ast_from_file(self, filepath: str, modname: str|None = None, fallback: bool = True, source: bool = False) -> nodes.Module: (source)

Given a module name, return the astroid object.

def ast_from_module(self, module: types.ModuleType, modname: str|None = None) -> nodes.Module: (source)

Given an imported module, return the astroid object.

def ast_from_module_name(self, modname: str|None, context_file: str|None = None, use_cache: bool = True) -> nodes.Module: (source)

Given a module name, return the astroid object.

def ast_from_string(self, data: str, modname: str = '', filepath: str|None = None) -> nodes.Module: (source)

Given some source code as a string, return its corresponding astroid object.

def bootstrap(self): (source)

Bootstrap the required AST modules needed for the manager to work. The bootstrap usually involves building the AST for the builtins module, which is required by the rest of astroid to work correctly.

def cache_module(self, module: nodes.Module): (source)

Cache a module if no module with the same name is known yet.

def clear_cache(self): (source)

Clear the underlying caches, bootstrap the builtins module and re-register transforms.

def file_from_module_name(self, modname: str, contextfile: str|None) -> spec.ModuleSpec: (source)

Undocumented

def infer_ast_from_something(self, obj: object, context: InferenceContext|None = None) -> Iterator[InferenceResult]: (source)

Infer astroid for the given class.

def register_failed_import_hook(self, hook: Callable[[str], nodes.Module]): (source)

Registers a hook to resolve imports that cannot be found otherwise. `hook` must be a function that accepts a single argument `modname` which contains the name of the module or package that could not be imported. If `hook` can resolve the import, must return a node of type `astroid.Module`, otherwise, it must raise `AstroidBuildingError`.

def visit_transforms(self, node: nodes.NodeNG) -> InferenceResult: (source)

Visit the transforms and apply them to the given *node*.

def zip_import_data(self, filepath: str) -> nodes.Module|None: (source)

Undocumented

max_inferable_values: ClassVar[int] = (source)

Undocumented

Undocumented

always_load_extensions = (source)

Undocumented

astroid_cache = (source)

Undocumented

extension_package_whitelist = (source)

Undocumented

optimize_ast = (source)

Undocumented

Undocumented

@property
register_transform = (source)

Undocumented

@property
unregister_transform = (source)

Undocumented

def _build_namespace_module(self, modname: str, path: Sequence[str]) -> nodes.Module: (source)

Undocumented

def _build_stub_module(self, modname: str) -> nodes.Module: (source)

Undocumented

def _can_load_extension(self, modname: str) -> bool: (source)

Undocumented

_failed_import_hooks = (source)

Undocumented

_mod_file_cache = (source)

Undocumented

_transform = (source)

Undocumented