diff --git a/jedi/api.py b/jedi/api.py index 3e467991..78d96b38 100644 --- a/jedi/api.py +++ b/jedi/api.py @@ -234,6 +234,10 @@ class Script(object): # do the magic functions first? and then recheck here? if not isinstance(s, evaluate.Function): if isinstance(s, imports.ImportPath): + if like == 'import': + l = self.module.get_line(self.pos[0])[:self.pos[1]] + if not l.endswith('import import'): + continue names = s.get_defined_names(on_import_stmt=True) else: names = s.get_defined_names() diff --git a/test/regression.py b/test/regression.py index 460ce1e1..3ba21b8d 100755 --- a/test/regression.py +++ b/test/regression.py @@ -105,6 +105,8 @@ class TestRegression(unittest.TestCase): assert 10 < len(self.complete("from .", (1, 5))) < 30 assert 10 < len(self.complete("from . import", (1, 5))) < 30 assert 10 < len(self.complete("from . import classes", (1, 5))) < 30 + assert len(self.complete("import")) == 0 + assert len(self.complete("import import")) > 0 def test_get_in_function_call(self): def check(call_def, name, index):