forked from VimPlug/jedi
Some small import completion fixes.
This commit is contained in:
@@ -54,6 +54,9 @@ def importer_from_error_statement(error_statement, pos):
|
|||||||
for typ, nodes in error_statement.stack:
|
for typ, nodes in error_statement.stack:
|
||||||
if typ == 'dotted_name':
|
if typ == 'dotted_name':
|
||||||
names += check_dotted(nodes)
|
names += check_dotted(nodes)
|
||||||
|
elif typ == 'import_name':
|
||||||
|
if nodes[0].start_pos <= pos <= nodes[0].end_pos:
|
||||||
|
return None, 0, False
|
||||||
elif typ == 'import_from':
|
elif typ == 'import_from':
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
if isinstance(node, pt.Node) and node.type == 'dotted_name':
|
if isinstance(node, pt.Node) and node.type == 'dotted_name':
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ Test of keywords and ``jedi.keywords``
|
|||||||
"""
|
"""
|
||||||
import jedi
|
import jedi
|
||||||
from jedi import Script, common
|
from jedi import Script, common
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
def test_goto_assignments_keyword():
|
def test_goto_assignments_keyword():
|
||||||
@@ -20,11 +19,8 @@ def test_keyword():
|
|||||||
defs = Script("print").goto_definitions()
|
defs = Script("print").goto_definitions()
|
||||||
assert [d.doc for d in defs]
|
assert [d.doc for d in defs]
|
||||||
|
|
||||||
with pytest.raises(jedi.NotFoundError):
|
assert Script("import").goto_assignments() == []
|
||||||
Script("import").goto_assignments()
|
|
||||||
|
|
||||||
completions = Script("import", 1, 1).completions()
|
completions = Script("import", 1, 1).completions()
|
||||||
assert len(completions) == 0
|
assert len(completions) > 10 and 'if' in [c.name for c in completions]
|
||||||
with common.ignored(jedi.NotFoundError): # TODO shouldn't throw that.
|
assert Script("assert").goto_definitions() == []
|
||||||
defs = Script("assert").goto_definitions()
|
|
||||||
assert len(defs) == 1
|
|
||||||
|
|||||||
Reference in New Issue
Block a user