summaryrefslogtreecommitdiff
path: root/astroid/objects.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/objects.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/objects.py')
-rw-r--r--astroid/objects.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/astroid/objects.py b/astroid/objects.py
index 1adc29ef..6597f3e8 100644
--- a/astroid/objects.py
+++ b/astroid/objects.py
@@ -23,6 +23,7 @@ from astroid import util
BUILTINS = six.moves.builtins.__name__
+objectmodel = util.lazy_import('interpreter.objectmodel')
class FrozenSet(node_classes._BaseContainer):
@@ -52,6 +53,8 @@ class Super(node_classes.NodeNG):
*self_class* is the class where the super call is, while
*scope* is the function where the super call is.
"""
+ special_attributes = util.lazy_descriptor(lambda: objectmodel.SuperModel())
+
# pylint: disable=super-init-not-called
def __init__(self, mro_pointer, mro_type, self_class, scope):
self.type = mro_type
@@ -59,12 +62,6 @@ class Super(node_classes.NodeNG):
self._class_based = False
self._self_class = self_class
self._scope = scope
- self._model = {
- '__thisclass__': self.mro_pointer,
- '__self_class__': self._self_class,
- '__self__': self.type,
- '__class__': self._proxied,
- }
def _infer(self, context=None):
yield self
@@ -120,9 +117,8 @@ class Super(node_classes.NodeNG):
def igetattr(self, name, context=None):
"""Retrieve the inferred values of the given attribute name."""
- local_name = self._model.get(name)
- if local_name:
- yield local_name
+ if name in self.special_attributes:
+ yield self.special_attributes.lookup(name)
return
try: