mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 15:24:46 +08:00
different solution for imports in davidhalter/jedi-vim#44
This commit is contained in:
@@ -237,7 +237,8 @@ class Script(object):
|
||||
# add keywords
|
||||
scopes |= keywords.get_keywords(string=goto_path, pos=self.pos)
|
||||
|
||||
d = set([api_classes.Definition(s) for s in scopes])
|
||||
d = set([api_classes.Definition(s) for s in scopes
|
||||
if not isinstance(s, imports.ImportPath._GlobalNamespace)])
|
||||
return sorted(d, key=lambda x: (x.module_path, x.start_pos))
|
||||
|
||||
def goto(self):
|
||||
|
||||
@@ -34,10 +34,7 @@ class BaseDefinition(object):
|
||||
self.is_keyword = isinstance(definition, keywords.Keyword)
|
||||
|
||||
# generate a path to the definition
|
||||
try:
|
||||
self.module_path = str(definition.get_parent_until().path)
|
||||
except AttributeError:
|
||||
self.module_path = None
|
||||
self.module_path = str(definition.get_parent_until().path)
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
@@ -231,8 +228,6 @@ class Definition(BaseDefinition):
|
||||
d = 'module %s' % self.module_name
|
||||
elif self.is_keyword:
|
||||
d = 'keyword %s' % d.name
|
||||
elif isinstance(d, type(imports.ImportPath.GlobalNamespace)):
|
||||
d = 'Global Namespace'
|
||||
else:
|
||||
d = d.get_code().replace('\n', '')
|
||||
return d
|
||||
|
||||
@@ -262,7 +262,7 @@ class TestRegression(Base):
|
||||
assert [d.doc for d in defs]
|
||||
|
||||
defs = self.get_def("import")
|
||||
print [d.doc for d in defs]
|
||||
assert len(defs) == 1
|
||||
assert [d.doc for d in defs]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user