forked from VimPlug/jedi
interpreter cleanup, use proper parents
This commit is contained in:
@@ -38,26 +38,33 @@ class LazyName(helpers.FakeName):
|
|||||||
@property
|
@property
|
||||||
@underscore_memoization
|
@underscore_memoization
|
||||||
def parent(self):
|
def parent(self):
|
||||||
parser_path = []
|
|
||||||
obj = self._value
|
obj = self._value
|
||||||
|
parser_path = []
|
||||||
if inspect.ismodule(obj):
|
if inspect.ismodule(obj):
|
||||||
module = obj
|
module = obj
|
||||||
else:
|
else:
|
||||||
|
class FakeParent(pr.Base):
|
||||||
|
parent = None # To avoid having no parent for NamePart.
|
||||||
|
path = None
|
||||||
|
|
||||||
|
names = []
|
||||||
try:
|
try:
|
||||||
o = obj.__objclass__
|
o = obj.__objclass__
|
||||||
parser_path.append(pr.NamePart(obj.__name__, None, (None, None)))
|
names.append(obj.__name__)
|
||||||
obj = o
|
obj = o
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
module_name = obj.__module__
|
module_name = obj.__module__
|
||||||
parser_path.insert(0, pr.NamePart(obj.__name__, None, (None, None)))
|
names.insert(0, obj.__name__)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
# Unfortunately in some cases like `int` there's no __module__
|
# Unfortunately in some cases like `int` there's no __module__
|
||||||
module = builtins
|
module = builtins
|
||||||
else:
|
else:
|
||||||
module = __import__(module_name)
|
module = __import__(module_name)
|
||||||
|
fake_name = helpers.FakeName(names, FakeParent)
|
||||||
|
parser_path = fake_name.names
|
||||||
raw_module = get_module(self._value)
|
raw_module = get_module(self._value)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user