diff --git a/jedi/inference/__init__.py b/jedi/inference/__init__.py index 88384db8..6ef69a24 100644 --- a/jedi/inference/__init__.py +++ b/jedi/inference/__init__.py @@ -308,7 +308,7 @@ class InferenceState(object): elif type_ == 'param': return [ParamName(context, name)] elif type_ in ('import_from', 'import_name'): - module_names = imports.infer_import(context, name, is_goto=True) + module_names = imports.goto_import(context, name) return module_names else: return [TreeNameDefinition(context, name)] diff --git a/jedi/inference/imports.py b/jedi/inference/imports.py index e37fbf95..3d4eeda1 100644 --- a/jedi/inference/imports.py +++ b/jedi/inference/imports.py @@ -57,7 +57,16 @@ class ModuleCache(object): # This memoization is needed, because otherwise we will infinitely loop on # certain imports. @inference_state_method_cache(default=NO_VALUES) -def infer_import(context, tree_name, is_goto=False): +def infer_import(context, tree_name): + return _infer_import(context, tree_name, is_goto=False) + + +@inference_state_method_cache(default=[]) +def goto_import(context, tree_name): + return _infer_import(context, tree_name, is_goto=True) + + +def _infer_import(context, tree_name, is_goto=False): module_context = context.get_root_context() import_node = search_ancestor(tree_name, 'import_name', 'import_from') import_path = import_node.get_path_for_name(tree_name)