mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 23:04:48 +08:00
goto on import statement (only import) raised an error
This commit is contained in:
@@ -342,7 +342,8 @@ class Script(object):
|
|||||||
|
|
||||||
:rtype: list of :class:`api_classes.Definition`
|
:rtype: list of :class:`api_classes.Definition`
|
||||||
"""
|
"""
|
||||||
d = [api_classes.Definition(d) for d in set(self._goto()[0])]
|
d = [api_classes.Definition(d) for d in set(self._goto()[0])
|
||||||
|
if not isinstance(d, imports.ImportPath._GlobalNamespace)]
|
||||||
return self._sorted_defs(d)
|
return self._sorted_defs(d)
|
||||||
|
|
||||||
def _goto(self, add_import_name=False):
|
def _goto(self, add_import_name=False):
|
||||||
|
|||||||
@@ -314,14 +314,16 @@ class TestRegression(TestBase):
|
|||||||
types = [o.type for o in objs]
|
types = [o.type for o in objs]
|
||||||
assert 'import' not in types and 'class' in types
|
assert 'import' not in types and 'class' in types
|
||||||
|
|
||||||
def test_keyword_definition_doc(self):
|
def test_keyword(self):
|
||||||
""" github jedi-vim issue #44 """
|
""" github jedi-vim issue #44 """
|
||||||
defs = self.goto_definitions("print")
|
defs = self.goto_definitions("print")
|
||||||
assert [d.doc for d in defs]
|
assert [d.doc for d in defs]
|
||||||
|
|
||||||
defs = self.goto_definitions("import")
|
defs = self.goto_definitions("import")
|
||||||
assert len(defs) == 1
|
assert len(defs) == 1 and [1 for d in defs if d.doc]
|
||||||
assert [d.doc for d in defs]
|
# unrelated to #44
|
||||||
|
defs = self.goto_assignments("import")
|
||||||
|
assert len(defs) == 0
|
||||||
|
|
||||||
def test_goto_following_on_imports(self):
|
def test_goto_following_on_imports(self):
|
||||||
s = "import multiprocessing.dummy; multiprocessing.dummy"
|
s = "import multiprocessing.dummy; multiprocessing.dummy"
|
||||||
|
|||||||
Reference in New Issue
Block a user