diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index 9cde1d42..ff46b43c 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -373,6 +373,8 @@ class Script(object): ) debug.speed('func_call followed') + # TODO here we use stubs instead of the actual contexts. We should use + # the signatures from stubs, but the actual contexts, probably?! return [classes.CallSignature(self._evaluator, signature, call_signature_details.bracket_leaf.start_pos, call_signature_details.call_index, diff --git a/jedi/api/helpers.py b/jedi/api/helpers.py index f7ce7536..e3f0259f 100644 --- a/jedi/api/helpers.py +++ b/jedi/api/helpers.py @@ -136,11 +136,14 @@ def get_stack_at_position(grammar, code_lines, module_node, pos): ) -def evaluate_goto_definition(evaluator, context, leaf): +def evaluate_goto_definition(evaluator, context, leaf, prefer_stubs=False): if leaf.type == 'name': # In case of a name we can just use goto_definition which does all the # magic itself. - return evaluator.goto_definitions(context, leaf) + if prefer_stubs: + return evaluator.goto_stub_definitions(context, leaf) + else: + return evaluator.goto_definitions(context, leaf) parent = leaf.parent if parent.type == 'atom': @@ -256,5 +259,6 @@ def cache_call_signatures(evaluator, context, bracket_leaf, code_lines, user_pos yield evaluate_goto_definition( evaluator, context, - bracket_leaf.get_previous_leaf() + bracket_leaf.get_previous_leaf(), + prefer_stubs=True, ) diff --git a/jedi/evaluate/__init__.py b/jedi/evaluate/__init__.py index ce458087..b6f83a8b 100644 --- a/jedi/evaluate/__init__.py +++ b/jedi/evaluate/__init__.py @@ -263,11 +263,11 @@ class Evaluator(object): def goto_definitions(self, context, name): # We don't want stubs here we want the actual contexts, if possible. return try_stubs_to_actual_context_set( - self._goto_definitions(context, name), + self.goto_stub_definitions(context, name), prefer_stub_to_compiled=True ) - def _goto_definitions(self, context, name): + def goto_stub_definitions(self, context, name): def_ = name.get_definition(import_name_always=True) if def_ is not None: type_ = def_.type