mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 05:54:25 +08:00
allow_descriptor_getattr -> allow_unsafe_interpreter_executions
This commit is contained in:
@@ -741,7 +741,8 @@ class Interpreter(Script):
|
||||
super().__init__(code, environment=environment, project=project, **kwds)
|
||||
|
||||
self.namespaces = namespaces
|
||||
self._inference_state.allow_descriptor_getattr = settings.instance_allow_descriptor_getattr
|
||||
self._inference_state.allow_unsafe_executions = \
|
||||
settings.allow_unsafe_interpreter_executions
|
||||
# Dynamic params search is important when we work on functions that are
|
||||
# called by other pieces of code. However for interpreter completions
|
||||
# this is not important at all, because the current code is always new
|
||||
|
||||
@@ -103,7 +103,7 @@ class InferenceState:
|
||||
self.is_analysis = False
|
||||
self.project = project
|
||||
self.access_cache = {}
|
||||
self.allow_descriptor_getattr = False
|
||||
self.allow_unsafe_executions = False
|
||||
self.flow_analysis_enabled = True
|
||||
|
||||
self.reset_recursion_limitations()
|
||||
|
||||
@@ -437,7 +437,7 @@ class CompiledValueFilter(AbstractFilter):
|
||||
|
||||
def get(self, name):
|
||||
access_handle = self.compiled_value.access_handle
|
||||
safe = not self._inference_state.allow_descriptor_getattr
|
||||
safe = not self._inference_state.allow_unsafe_executions
|
||||
return self._get(
|
||||
name,
|
||||
lambda name: access_handle.is_allowed_getattr(name, safe=safe),
|
||||
@@ -464,7 +464,7 @@ class CompiledValueFilter(AbstractFilter):
|
||||
return []
|
||||
|
||||
if (is_descriptor or not has_attribute) \
|
||||
and not self._inference_state.allow_descriptor_getattr:
|
||||
and not self._inference_state.allow_unsafe_executions:
|
||||
return [self._get_cached_name(name, is_empty=True)]
|
||||
|
||||
if self.is_instance and not in_dir_callback(name):
|
||||
|
||||
@@ -143,10 +143,13 @@ This improves autocompletion for libraries that use ``setattr`` or
|
||||
``globals()`` modifications a lot.
|
||||
"""
|
||||
|
||||
instance_allow_descriptor_getattr = True
|
||||
allow_unsafe_interpreter_executions = True
|
||||
"""
|
||||
Controls whether descriptors are evaluated when using an Interpreter. This is
|
||||
something you might want to control when using Jedi from a Repl (e.g. IPython)
|
||||
|
||||
Generally this setting allows Jedi to execute __getitem__ and descriptors like
|
||||
`property`.
|
||||
"""
|
||||
|
||||
# ----------------
|
||||
|
||||
@@ -222,7 +222,7 @@ def test__getattr__completions(allow_unsafe_getattr, class_is_findable):
|
||||
|
||||
@pytest.fixture(params=[False, True])
|
||||
def allow_unsafe_getattr(request, monkeypatch):
|
||||
monkeypatch.setattr(jedi.settings,'instance_allow_descriptor_getattr', request.param)
|
||||
monkeypatch.setattr(jedi.settings, 'allow_unsafe_interpreter_executions', request.param)
|
||||
return request.param
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user