mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
instance_allow_descriptor_getattr as public setting
This commit is contained in:
@@ -708,7 +708,6 @@ class Interpreter(Script):
|
||||
:param namespaces: A list of namespace dictionaries such as the one
|
||||
returned by :func:`globals` and :func:`locals`.
|
||||
"""
|
||||
_allow_descriptor_getattr_default = True
|
||||
|
||||
def __init__(self, code, namespaces, *, project=None, **kwds):
|
||||
try:
|
||||
@@ -729,7 +728,7 @@ class Interpreter(Script):
|
||||
super().__init__(code, environment=environment, project=project, **kwds)
|
||||
|
||||
self.namespaces = namespaces
|
||||
self._inference_state.allow_descriptor_getattr = self._allow_descriptor_getattr_default
|
||||
self._inference_state.allow_descriptor_getattr = settings.instance_allow_descriptor_getattr
|
||||
|
||||
@cache.memoize_method
|
||||
def _get_module_context(self):
|
||||
|
||||
@@ -143,6 +143,12 @@ This improves autocompletion for libraries that use ``setattr`` or
|
||||
``globals()`` modifications a lot.
|
||||
"""
|
||||
|
||||
instance_allow_descriptor_getattr = 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)
|
||||
"""
|
||||
|
||||
# ----------------
|
||||
# Caching Validity
|
||||
# ----------------
|
||||
|
||||
@@ -8,6 +8,7 @@ import typing
|
||||
import pytest
|
||||
|
||||
import jedi
|
||||
import jedi.settings
|
||||
from jedi.inference.compiled import mixed
|
||||
from importlib import import_module
|
||||
|
||||
@@ -219,7 +220,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.Interpreter, '_allow_descriptor_getattr_default', request.param)
|
||||
monkeypatch.setattr(jedi.settings,'instance_allow_descriptor_getattr', request.param)
|
||||
return request.param
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user