コード例 #1
0
def brainless_manager():
    m = manager.AstroidManager()
    # avoid caching into the AstroidManager borg since we get problems
    # with other tests :
    m.__dict__ = {}
    m._failed_import_hooks = []
    m.astroid_cache = {}
    m._mod_file_cache = {}
    m._transform = transforms.TransformVisitor()
    m.extension_package_whitelist = {}
    return m
コード例 #2
0
def _object_type(node, context=None):
    astroid_manager = manager.AstroidManager()
    builtins = astroid_manager.builtins_module
    context = context or contextmod.InferenceContext()

    for inferred in node.infer(context=context):
        if isinstance(inferred, scoped_nodes.ClassDef):
            if inferred.newstyle:
                metaclass = inferred.metaclass(context=context)
                if metaclass:
                    yield metaclass
                    continue
            yield builtins.getattr("type")[0]
        elif isinstance(inferred, (scoped_nodes.Lambda, bases.UnboundMethod)):
            yield _function_type(inferred, builtins)
        elif isinstance(inferred, scoped_nodes.Module):
            yield _build_proxy_class("module", builtins)
        else:
            yield inferred._proxied
コード例 #3
0
ファイル: inference.py プロジェクト: PolPasop/ec-cor-survey
import itertools
import operator

import wrapt
from astroid import bases
from astroid import context as contextmod
from astroid import exceptions
from astroid import decorators
from astroid import helpers
from astroid import manager
from astroid import nodes
from astroid.interpreter import dunder_lookup
from astroid import protocols
from astroid import util

MANAGER = manager.AstroidManager()
# Prevents circular imports
objects = util.lazy_import("objects")

# .infer method ###############################################################


def infer_end(self, context=None):
    """Inference's end for nodes that yield themselves on inference

    These are objects for which inference does not have any semantic,
    such as Module or Consts.
    """
    yield self

コード例 #4
0
 def setUp(self):
     super(AstroidManagerTest, self).setUp()
     self.manager = manager.AstroidManager()
     self.manager.clear_cache(self._builtins)  # take care of borg
コード例 #5
0
ファイル: helpers.py プロジェクト: prihit/we-care
def _object_type(node, context=None):
    astroid_manager = manager.AstroidManager()
コード例 #6
0
 def setUp(self) -> None:
     builtins_name = builtins.__name__
     astroid_manager = manager.AstroidManager()
     self.builtins = astroid_manager.astroid_cache[builtins_name]
     self.manager = manager.AstroidManager()
コード例 #7
0
 def setUp(self):
     super(AstroidManagerTest, self).setUp()
     self.manager = manager.AstroidManager()