mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +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.
|
# to push the star imports into Evaluator.module_cache, if we reenable this.
|
||||||
@evaluator_method_cache([])
|
@evaluator_method_cache([])
|
||||||
def star_imports(self):
|
def star_imports(self):
|
||||||
from jedi.evaluate.imports import infer_import
|
from jedi.evaluate.imports import Importer
|
||||||
|
|
||||||
modules = []
|
modules = []
|
||||||
for i in self.tree_node.iter_imports():
|
for i in self.tree_node.iter_imports():
|
||||||
if i.is_star_import():
|
if i.is_star_import():
|
||||||
name = i.get_paths()[-1][-1]
|
new = Importer(
|
||||||
new = infer_import(self, name)
|
self.evaluator,
|
||||||
|
import_path=i.get_paths()[-1],
|
||||||
|
module_context=self,
|
||||||
|
level=i.level
|
||||||
|
).follow()
|
||||||
|
|
||||||
for module in new:
|
for module in new:
|
||||||
if isinstance(module, ModuleContext):
|
if isinstance(module, ModuleContext):
|
||||||
modules += module.star_imports()
|
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()]
|
names = [c.name for c in Script('xzy; from abc import ').completions()]
|
||||||
assert 'ABCMeta' in names
|
assert 'ABCMeta' in names
|
||||||
assert 'abc' not 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