diff options
author | Emile Anclin <emile.anclin@logilab.fr> | 2010-02-17 09:33:10 +0100 |
---|---|---|
committer | Emile Anclin <emile.anclin@logilab.fr> | 2010-02-17 09:33:10 +0100 |
commit | fc5c916b68953364f03df49918c1a4c6218f4601 (patch) | |
tree | 74a97d66912b4c0164d55d01cd73568f86708978 /infutils.py | |
parent | 799a6102edc88757ee0e35dbfc8db32bac67ad59 (diff) | |
download | astroid-git-fc5c916b68953364f03df49918c1a4c6218f4601.tar.gz |
update inference and infutils from default/stable branch
--HG--
branch : rebuild
Diffstat (limited to 'infutils.py')
-rw-r--r-- | infutils.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/infutils.py b/infutils.py index 38d32a71..c74fbd54 100644 --- a/infutils.py +++ b/infutils.py @@ -222,12 +222,8 @@ class Instance(Proxy): if '__builtin__.property' in attr.decoratornames(): for infered in attr.infer_call_result(self, context): yield infered - elif attr.type in ('method', 'classmethod'): - # XXX could get some information from the bound node: - # self (if method) or self._proxied (if class method) - yield BoundMethod(attr) else: - yield attr + yield BoundMethod(attr, self) else: yield attr @@ -259,6 +255,9 @@ class Instance(Proxy): def pytype(self): return self._proxied.qname() + def display_type(self): + return 'Instance of' + class UnboundMethod(Proxy): """a special node representing a method not bound to an instance""" @@ -284,9 +283,18 @@ class UnboundMethod(Proxy): class BoundMethod(UnboundMethod): """a special node representing a method bound to an instance""" + def __init__(self, proxy, bound): + UnboundMethod.__init__(self, proxy) + self.bound = bound + def is_bound(self): return True + def infer_call_result(self, caller, context): + context = context.clone() + context.boundnode = self.bound + return self._proxied.infer_call_result(caller, context) + class Generator(Proxy): """a special node representing a generator""" @@ -296,4 +304,6 @@ class Generator(Proxy): def pytype(self): return '__builtin__.generator' + def display_type(self): + return 'Generator' |