forked from VimPlug/jedi
variable assignments for classes prepared
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user