diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index 24087a42..257f8c8d 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -304,7 +304,10 @@ class Script(object): if call_signature_details is None: return [] - context = self._evaluator.create_context(call_signature_details.bracket_leaf) + context = self._evaluator.create_context( + self._get_module(), + call_signature_details.bracket_leaf + ) with common.scale_speed_settings(settings.scale_call_signatures): definitions = helpers.cache_call_signatures( self._evaluator, diff --git a/jedi/api/completion.py b/jedi/api/completion.py index 9eb91604..b1f487cd 100644 --- a/jedi/api/completion.py +++ b/jedi/api/completion.py @@ -15,7 +15,7 @@ def get_call_signature_param_names(call_signatures): # add named params for call_sig in call_signatures: # Allow protected access, because it's a public API. - module = call_sig._name.get_parent_until() + module = call_sig._name.get_root_context() # Compiled modules typically don't allow keyword arguments. if not isinstance(module, compiled.CompiledObject): for p in call_sig.params: diff --git a/jedi/evaluate/context.py b/jedi/evaluate/context.py index 7b60c119..9e2a4412 100644 --- a/jedi/evaluate/context.py +++ b/jedi/evaluate/context.py @@ -99,9 +99,17 @@ class LazyTreeContext(AbstractLazyContext): def __init__(self, context, node): super(LazyTreeContext, self).__init__(node) self._context = context + # We need to save the predefined names. It's an unfortunate side effect + # that needs to be tracked otherwise results will be wrong. + self._predefined_names = dict(context.predefined_names) def infer(self): - return self._context.eval_node(self.data) + old, self._context.predefined_names = \ + self._context.predefined_names, self._predefined_names + try: + return self._context.eval_node(self.data) + finally: + self._context.predefined_names = old def get_merged_lazy_context(lazy_contexts):