diff options
author | Julien Jehannet <julien.jehannet@logilab.fr> | 2011-01-18 09:50:25 +0100 |
---|---|---|
committer | Julien Jehannet <julien.jehannet@logilab.fr> | 2011-01-18 09:50:25 +0100 |
commit | db7ea8451a98b437ee635e99d83944f2a9d3acc2 (patch) | |
tree | 0316a63d8dcd1244056c5bedf4f77aba9e5ed986 /inference.py | |
parent | a73ee39ee8abb46d5785f890295aa128766927ed (diff) | |
parent | 3c3c34d9706ff5f9cea065b5544f18a36bb8216c (diff) | |
download | astroid-git-db7ea8451a98b437ee635e99d83944f2a9d3acc2.tar.gz |
(merge py3k changes)
Diffstat (limited to 'inference.py')
-rw-r--r-- | inference.py | 45 |
1 files changed, 4 insertions, 41 deletions
diff --git a/inference.py b/inference.py index 25c5fed5..edc71839 100644 --- a/inference.py +++ b/inference.py @@ -20,59 +20,22 @@ """this module contains a set of functions to handle inference on astng trees """ -from __future__ import generators - __doctype__ = "restructuredtext en" from itertools import chain import sys -try: - GeneratorExit # introduced in py2.5 -except NameError: - class GeneratorExit(Exception): pass +from logilab.astng import nodes -from logilab.astng import nodes, raw_building from logilab.astng.manager import ASTNGManager -from logilab.astng import ASTNGError, InferenceError, UnresolvableName, \ - NoDefault, NotFoundError, ASTNGBuildingException -from logilab.astng.bases import YES, Instance, InferenceContext, \ +from logilab.astng.exceptions import (ASTNGBuildingException, ASTNGError, + InferenceError, NoDefault, NotFoundError, UnresolvableName) +from logilab.astng.bases import YES, Instance, InferenceContext, Generator, \ _infer_stmts, copy_context, path_wrapper, raise_if_nothing_infered from logilab.astng.protocols import _arguments_infer_argname MANAGER = ASTNGManager() -_CONST_PROXY = { - type(None): raw_building.build_class('NoneType'), - bool: MANAGER.astng_from_class(bool), - int: MANAGER.astng_from_class(int), - long: MANAGER.astng_from_class(long), - float: MANAGER.astng_from_class(float), - complex: MANAGER.astng_from_class(complex), - str: MANAGER.astng_from_class(str), - unicode: MANAGER.astng_from_class(unicode), - } -_CONST_PROXY[type(None)].parent = _CONST_PROXY[bool].parent -if sys.version_info >= (2, 6): - _CONST_PROXY[bytes] = MANAGER.astng_from_class(bytes) - -# TODO : find a nicer way to handle this situation; we should at least -# be able to avoid calling MANAGER.astng_from_class(const.value.__class__) -# each time (if we can not avoid the property). However __proxied introduced an -# infinite recursion (see https://bugs.launchpad.net/pylint/+bug/456870) -def _set_proxied(const): - return _CONST_PROXY[const.value.__class__] -nodes.Const._proxied = property(_set_proxied) - -def Const_pytype(self): - return self._proxied.qname() -nodes.Const.pytype = Const_pytype - - -nodes.List._proxied = MANAGER.astng_from_class(list) -nodes.Tuple._proxied = MANAGER.astng_from_class(tuple) -nodes.Dict._proxied = MANAGER.astng_from_class(dict) - class CallContext: """when inferring a function call, this class is used to remember values |