mirror of
https://github.com/davidhalter/jedi.git
synced 2026-01-09 13:32:20 +08:00
Fix side effect issues with predefined names and lazy contexts.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user