forked from VimPlug/jedi
using super() in actual executed classes wasn't possible. fixes #421
This commit is contained in:
@@ -176,7 +176,7 @@ class Instance(use_metaclass(CachedMetaClass, Executable)):
|
||||
|
||||
def __getattr__(self, name):
|
||||
if name not in ['start_pos', 'end_pos', 'name', 'get_imports',
|
||||
'doc', 'raw_doc', 'asserts']:
|
||||
'doc', 'raw_doc', 'asserts', 'py_bases']:
|
||||
raise AttributeError("Instance %s: Don't touch this (%s)!"
|
||||
% (self, name))
|
||||
return getattr(self.base, name)
|
||||
|
||||
@@ -91,11 +91,13 @@ class SuperInstance(er.Instance):
|
||||
|
||||
def builtins_super(evaluator, obj, params):
|
||||
# TODO make this able to detect multiple inheritance super
|
||||
accept = (pr.Function,)
|
||||
accept = (pr.Function, er.FunctionExecution)
|
||||
func = params.get_parent_until(accept)
|
||||
if func.isinstance(*accept):
|
||||
cls = func.get_parent_until(accept + (pr.Class,),
|
||||
wanted = (pr.Class, er.Instance)
|
||||
cls = func.get_parent_until(accept + wanted,
|
||||
include_current=False)
|
||||
if isinstance(cls, wanted):
|
||||
if isinstance(cls, pr.Class):
|
||||
cls = er.Class(evaluator, cls)
|
||||
su = cls.py_bases()
|
||||
|
||||
@@ -398,6 +398,8 @@ PrivateVar().__var
|
||||
# -----------------
|
||||
class Super(object):
|
||||
a = 3
|
||||
def return_sup(self):
|
||||
return 1
|
||||
|
||||
class TestSuper(Super):
|
||||
#?
|
||||
@@ -414,6 +416,13 @@ class TestSuper(Super):
|
||||
#?
|
||||
super()
|
||||
|
||||
def return_sup(self):
|
||||
#? int()
|
||||
return super().return_sup()
|
||||
|
||||
#? int()
|
||||
TestSuper().return_sup()
|
||||
|
||||
|
||||
# -----------------
|
||||
# if flow at class level
|
||||
|
||||
Reference in New Issue
Block a user