def build_class(name, basenames=(), doc=None): """create and initialize a astroid Class node""" node = Class(name, doc) for base in basenames: basenode = Name() basenode.name = base node.bases.append(basenode) basenode.parent = node return node
from logilab.common.compat import builtins astroid_builtin = Astroid_BUILDER.inspect_build(builtins) for cls, node_cls in CONST_CLS.items(): if cls is type(None): proxy = build_class('NoneType') proxy.parent = astroid_builtin else: proxy = astroid_builtin.getattr(cls.__name__)[0] if cls in (dict, list, set, tuple): node_cls._proxied = proxy else: _CONST_PROXY[cls] = proxy _astroid_bootstrapping() # TODO : find a nicer way to handle this situation; # However __proxied introduced an # infinite recursion (see https://bugs.launchpad.net/pylint/+bug/456870) def _set_proxied(const): return _CONST_PROXY[const.value.__class__] Const._proxied = property(_set_proxied) from types import GeneratorType Generator._proxied = Class(GeneratorType.__name__, GeneratorType.__doc__) Astroid_BUILDER.object_build(Generator._proxied, GeneratorType)