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 getattr / __getattr__ / __getattribute__ ?
|
||||||
TODO descriptors
|
TODO descriptors
|
||||||
TODO @staticmethod @classmethod
|
TODO @staticmethod @classmethod
|
||||||
|
TODO variable assignments in classes (see test/completion/classes @230)
|
||||||
"""
|
"""
|
||||||
from _compatibility import next, property
|
from _compatibility import next, property
|
||||||
import sys
|
import sys
|
||||||
@@ -866,9 +867,13 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
|
|||||||
else:
|
else:
|
||||||
inst = Instance(Class(par.parent.parent))
|
inst = Instance(Class(par.parent.parent))
|
||||||
result.append(inst)
|
result.append(inst)
|
||||||
elif isinstance(par, InstanceElement) \
|
elif isinstance(par, (InstanceElement)) \
|
||||||
and hasattr(par, 'get_descriptor_return'):
|
and hasattr(par, 'get_descriptor_return'):
|
||||||
try:
|
try:
|
||||||
|
#print '\n\n'
|
||||||
|
#print name, par
|
||||||
|
#print par.get_descriptor_return(scope)
|
||||||
|
#raise KeyError()
|
||||||
result += par.get_descriptor_return(scope)
|
result += par.get_descriptor_return(scope)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
result.append(par)
|
result.append(par)
|
||||||
|
|||||||
@@ -182,16 +182,26 @@ class B():
|
|||||||
@Property
|
@Property
|
||||||
def r(self):
|
def r(self):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@r.setter
|
@r.setter
|
||||||
def r(self, value):
|
def r(self, value):
|
||||||
pass
|
pass
|
||||||
|
def t(self):
|
||||||
|
return ''
|
||||||
|
p = Property(t)
|
||||||
|
|
||||||
|
##? str()
|
||||||
|
B().p
|
||||||
#? []
|
#? []
|
||||||
B().r()
|
B().r()
|
||||||
#? int()
|
#? int()
|
||||||
B().r
|
B().r
|
||||||
|
|
||||||
|
##? []
|
||||||
|
B().p()
|
||||||
|
|
||||||
|
# -----------------
|
||||||
|
# class decorators
|
||||||
|
# -----------------
|
||||||
class Decorator(object):
|
class Decorator(object):
|
||||||
def __init__(self, func):
|
def __init__(self, func):
|
||||||
self.func = func
|
self.func = func
|
||||||
@@ -207,3 +217,19 @@ def nothing(a,b,c):
|
|||||||
nothing("")[0]
|
nothing("")[0]
|
||||||
#? str()
|
#? str()
|
||||||
nothing("")[1]
|
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