mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
inheritance
This commit is contained in:
10
evaluate.py
10
evaluate.py
@@ -200,6 +200,14 @@ class Class(object):
|
|||||||
self.base = base
|
self.base = base
|
||||||
|
|
||||||
def get_defined_names(self, as_instance=False):
|
def get_defined_names(self, as_instance=False):
|
||||||
|
def in_iterable(name, iterable):
|
||||||
|
for i in iterable:
|
||||||
|
# only the last name is important, because these names have a
|
||||||
|
# maximal length of 2, with the first one being `self`.
|
||||||
|
if i.names[-1] == name.names[-1]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
names = self.base.get_defined_names()
|
names = self.base.get_defined_names()
|
||||||
|
|
||||||
# check super classes:
|
# check super classes:
|
||||||
@@ -209,7 +217,7 @@ class Class(object):
|
|||||||
if as_instance:
|
if as_instance:
|
||||||
cls = Instance(cls)
|
cls = Instance(cls)
|
||||||
for i in cls.get_defined_names():
|
for i in cls.get_defined_names():
|
||||||
if not i.in_iterable(names):
|
if not in_iterable(i, names):
|
||||||
names.append(i)
|
names.append(i)
|
||||||
return names
|
return names
|
||||||
|
|
||||||
|
|||||||
@@ -884,13 +884,6 @@ class Name(Simple):
|
|||||||
""" Returns the names in a full string format """
|
""" Returns the names in a full string format """
|
||||||
return ".".join(self.names)
|
return ".".join(self.names)
|
||||||
|
|
||||||
def in_iterable(self, iterable):
|
|
||||||
for i in iterable:
|
|
||||||
if i.names == self.names:
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.get_code()
|
return self.get_code()
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,15 @@ a.real
|
|||||||
#? ['upper']
|
#? ['upper']
|
||||||
a.upper
|
a.upper
|
||||||
|
|
||||||
|
a = tuple
|
||||||
|
if 1:
|
||||||
|
a = list
|
||||||
|
|
||||||
|
#? ['append']
|
||||||
|
a.append
|
||||||
|
#? ['index']
|
||||||
|
a.index
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# tuples exchanges
|
# tuples exchanges
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|||||||
Reference in New Issue
Block a user