mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Fix star imports checks, fixes #1235
This commit is contained in:
@@ -145,13 +145,18 @@ class ModuleMixin(SubModuleDictMixin):
|
||||
# to push the star imports into Evaluator.module_cache, if we reenable this.
|
||||
@evaluator_method_cache([])
|
||||
def star_imports(self):
|
||||
from jedi.evaluate.imports import infer_import
|
||||
from jedi.evaluate.imports import Importer
|
||||
|
||||
modules = []
|
||||
for i in self.tree_node.iter_imports():
|
||||
if i.is_star_import():
|
||||
name = i.get_paths()[-1][-1]
|
||||
new = infer_import(self, name)
|
||||
new = Importer(
|
||||
self.evaluator,
|
||||
import_path=i.get_paths()[-1],
|
||||
module_context=self,
|
||||
level=i.level
|
||||
).follow()
|
||||
|
||||
for module in new:
|
||||
if isinstance(module, ModuleContext):
|
||||
modules += module.star_imports()
|
||||
|
||||
@@ -462,3 +462,16 @@ def test_import_with_semicolon(Script):
|
||||
names = [c.name for c in Script('xzy; from abc import ').completions()]
|
||||
assert 'ABCMeta' in names
|
||||
assert 'abc' not in names
|
||||
|
||||
|
||||
def test_relative_import_star(Script):
|
||||
# Coming from github #1235
|
||||
import jedi
|
||||
|
||||
source = """
|
||||
from . import *
|
||||
furl.c
|
||||
"""
|
||||
script = jedi.Script(source,3,len("furl.c"), 'export.py')
|
||||
|
||||
assert script.completions()
|
||||
|
||||
Reference in New Issue
Block a user