summaryrefslogtreecommitdiff
path: root/astroid/util.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2016-06-03 20:26:18 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2016-06-03 20:30:30 +0100
commit2e8c48123419e4aafc91e1f35bc9b3f35541cb68 (patch)
treeb1d97737c87949b623d590d83a7d6977ae8a92cc /astroid/util.py
parent3e27213914271309a4716662b09fda91fca9efa1 (diff)
downloadastroid-git-2e8c48123419e4aafc91e1f35bc9b3f35541cb68.tar.gz
Introduce a special attributes model
Through this model, astroid starts knowing special attributes of certain Python objects, such as functions, classes, super objects and so on. This was previously possible before, but now the lookup and the attributes themselves are separated into a new module, objectmodel.py, which describes, in a more comprehensive way, the data model of each object.
Diffstat (limited to 'astroid/util.py')
-rw-r--r--astroid/util.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/astroid/util.py b/astroid/util.py
index 5c506b59..1111202f 100644
--- a/astroid/util.py
+++ b/astroid/util.py
@@ -8,10 +8,23 @@
import sys
import warnings
+import importlib
import lazy_object_proxy
import six
+def lazy_descriptor(obj):
+ class DescriptorProxy(lazy_object_proxy.Proxy):
+ def __get__(self, instance, owner=None):
+ return self.__class__.__get__(self, instance)
+ return DescriptorProxy(obj)
+
+
+def lazy_import(module_name):
+ return lazy_object_proxy.Proxy(
+ lambda: importlib.import_module('.' + module_name, 'astroid'))
+
+
def reraise(exception):
'''Reraises an exception with the traceback from the current exception
block.'''