mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
A CompiledInstance is not really compiled, it's an instance of a compiled class value
This commit is contained in:
@@ -112,6 +112,8 @@ class AbstractInstanceValue(Value):
|
||||
|
||||
|
||||
class CompiledInstance(AbstractInstanceValue):
|
||||
# This is not really a compiled class, it's just an instance from a
|
||||
# compiled class.
|
||||
def __init__(self, inference_state, parent_context, class_value, arguments):
|
||||
super(CompiledInstance, self).__init__(inference_state, parent_context,
|
||||
class_value)
|
||||
@@ -130,9 +132,6 @@ class CompiledInstance(AbstractInstanceValue):
|
||||
def name(self):
|
||||
return compiled.CompiledValueName(self, self.class_value.name.string_name)
|
||||
|
||||
def is_compiled(self):
|
||||
return True
|
||||
|
||||
def is_stub(self):
|
||||
return False
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ from . import refactor
|
||||
|
||||
import jedi
|
||||
from jedi.api.environment import InterpreterEnvironment
|
||||
from jedi.inference.compiled.value import create_from_access_path
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
@@ -135,3 +136,11 @@ def same_process_inference_state(Script):
|
||||
def disable_typeshed(monkeypatch):
|
||||
from jedi.inference.gradual import typeshed
|
||||
monkeypatch.setattr(typeshed, '_load_from_typeshed', lambda *args, **kwargs: None)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_compiled_object(inference_state):
|
||||
return lambda obj: create_from_access_path(
|
||||
inference_state,
|
||||
inference_state.compiled_subprocess.create_simple_object(obj)
|
||||
)
|
||||
|
||||
@@ -9,6 +9,7 @@ import pytest
|
||||
from jedi.inference import compiled
|
||||
from jedi.inference.compiled.access import DirectObjectAccess
|
||||
from jedi.inference.gradual.conversion import _stub_to_python_value_set
|
||||
from jedi.inference.syntax_tree import _infer_comparison_part
|
||||
|
||||
|
||||
def test_simple(inference_state, environment):
|
||||
@@ -169,3 +170,15 @@ def test_qualified_names(same_process_inference_state, obj, expected_names):
|
||||
DirectObjectAccess(same_process_inference_state, obj)
|
||||
)
|
||||
assert o.get_qualified_names() == tuple(expected_names)
|
||||
|
||||
|
||||
def test_operation(Script, inference_state, create_compiled_object):
|
||||
#b = create_simple_object(inference_state, 'bool')._compiled_obj
|
||||
b = create_compiled_object(bool)
|
||||
true, = _infer_comparison_part(
|
||||
inference_state, b.parent_context,
|
||||
left=list(b.execute_with_values())[0],
|
||||
operator='is not',
|
||||
right=b,
|
||||
)
|
||||
assert true.py__name__() == 'bool'
|
||||
|
||||
Reference in New Issue
Block a user