1
0
forked from VimPlug/jedi

Use the subprocess access to create acceses

This commit is contained in:
Dave Halter
2017-12-06 15:06:48 +01:00
parent f09ca9fc20
commit 42fb93dc01
3 changed files with 14 additions and 15 deletions

View File

@@ -27,12 +27,12 @@ def create(evaluator, obj):
def get_special_object(evaluator, identifier):
return create_from_access_path(
evaluator,
access.get_special_object(evaluator, identifier)
evaluator.compiled_subprocess.get_special_object(identifier)
)
def load_module(evaluator, path=None, name=None):
return create_from_access_path(
evaluator,
access.load_module(evaluator, path=path, name=name)
evaluator.compiled_subprocess.load_module(path=path, name=name)
)

View File

@@ -1,16 +1,13 @@
import sys
from jedi.evaluate import compiled
from jedi.evaluate.compiled import access
def get_sys_path():
return sys.path
def import_module(evaluator, handles, path=None, name=None):
compiled_object = compiled.load_module(evaluator, path=path, name=name)
if compiled_object is None:
return None
return handles.create(compiled_object)
def load_module(evaluator, path=None, name=None):
return access.load_module(evaluator, path=path, name=name)
def get_compiled_method_return(evaluator, id, attribute, *args, **kwargs):
@@ -18,5 +15,5 @@ def get_compiled_method_return(evaluator, id, attribute, *args, **kwargs):
return getattr(handle.access, attribute)(*args, **kwargs)
def get_special_object(evaluator, handles, identifier):
return compiled.get_special_object(evaluator, identifier)
def get_special_object(evaluator, identifier):
return access.get_special_object(evaluator, identifier)

View File

@@ -28,9 +28,11 @@ def test_versions(version):
assert any(executable in p for p in sys_path)
def test_import_module(evaluator):
compiled_obj = evaluator.compiled_subprocess.import_module(name='math')
assert compiled_obj.py__bool__() is True
assert compiled_obj.api_type == 'module'
def test_load_module(evaluator):
access_path = evaluator.compiled_subprocess.load_module(name='math')
name, access_handle = access_path.accesses[0]
assert access_handle.py__bool__() is True
assert access_handle.get_api_type() == 'module'
with pytest.raises(AttributeError):
assert compiled_obj.py__mro__()
access_handle.py__mro__()