From 983de9820f55aefa8ef7af13246ea83c9bb9b233 Mon Sep 17 00:00:00 2001 From: David Halter Date: Sat, 23 Jun 2012 18:26:36 +0200 Subject: [PATCH] variable assignments for classes prepared --- evaluate.py | 7 ++++++- test/completion/classes.py | 28 +++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/evaluate.py b/evaluate.py index fdca64cc..b338290b 100644 --- a/evaluate.py +++ b/evaluate.py @@ -16,6 +16,7 @@ TODO nonlocal statement TODO getattr / __getattr__ / __getattribute__ ? TODO descriptors TODO @staticmethod @classmethod +TODO variable assignments in classes (see test/completion/classes @230) """ from _compatibility import next, property import sys @@ -866,9 +867,13 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False): else: inst = Instance(Class(par.parent.parent)) result.append(inst) - elif isinstance(par, InstanceElement) \ + elif isinstance(par, (InstanceElement)) \ and hasattr(par, 'get_descriptor_return'): try: + #print '\n\n' + #print name, par + #print par.get_descriptor_return(scope) + #raise KeyError() result += par.get_descriptor_return(scope) except KeyError: result.append(par) diff --git a/test/completion/classes.py b/test/completion/classes.py index b9e201aa..7f390014 100644 --- a/test/completion/classes.py +++ b/test/completion/classes.py @@ -182,16 +182,26 @@ class B(): @Property def r(self): return 1 - @r.setter def r(self, value): pass + def t(self): + return '' + p = Property(t) +##? str() +B().p #? [] B().r() #? int() B().r +##? [] +B().p() + +# ----------------- +# class decorators +# ----------------- class Decorator(object): def __init__(self, func): self.func = func @@ -207,3 +217,19 @@ def nothing(a,b,c): nothing("")[0] #? str() nothing("")[1] + +# ----------------- +# variable assignments +# ----------------- + +class V: + def __init__(self): + self.a = 1 + + def ret(self): + return self.a + + b = ret + +##? int() +V().b()