forked from VimPlug/jedi
Fix some interpreter issues
This commit is contained in:
@@ -96,6 +96,21 @@ class MixedName(compiled.CompiledName):
|
||||
|
||||
@underscore_memoization
|
||||
def infer(self):
|
||||
def access_to_value(parent_value, access):
|
||||
if parent_value is None:
|
||||
parent_context = None
|
||||
else:
|
||||
parent_context = parent_value.as_context()
|
||||
|
||||
if parent_context is None or isinstance(parent_context, MixedObject):
|
||||
return _create(self._inference_state, access, parent_context=parent_context)
|
||||
else:
|
||||
return ValueSet({
|
||||
create_cached_compiled_object(
|
||||
parent_context.inference_state, access, parent_context
|
||||
)
|
||||
})
|
||||
|
||||
# TODO use logic from compiled.CompiledObjectFilter
|
||||
access_paths = self.parent_context.access_handle.getattr_paths(
|
||||
self.string_name,
|
||||
@@ -104,12 +119,7 @@ class MixedName(compiled.CompiledName):
|
||||
assert len(access_paths)
|
||||
values = [None]
|
||||
for access in access_paths:
|
||||
values = ValueSet.from_sets(
|
||||
_create(self._inference_state, access, parent_context=c)
|
||||
if c is None or isinstance(c, MixedObject)
|
||||
else ValueSet({create_cached_compiled_object(c.inference_state, access, c)})
|
||||
for c in values
|
||||
)
|
||||
values = ValueSet.from_sets(access_to_value(v, access) for v in values)
|
||||
return values
|
||||
|
||||
@property
|
||||
@@ -278,7 +288,8 @@ def _create(inference_state, access_handle, parent_context, *args):
|
||||
tree_node,
|
||||
node_is_value=True,
|
||||
node_is_object=True
|
||||
)
|
||||
)._value
|
||||
# TODO private access!
|
||||
})
|
||||
if tree_node.type == 'classdef':
|
||||
if not access_handle.is_class():
|
||||
|
||||
@@ -17,7 +17,7 @@ from jedi.inference.compiled.access import _sentinel
|
||||
from jedi.inference.cache import inference_state_function_cache
|
||||
from jedi.inference.helpers import reraise_getitem_errors
|
||||
from jedi.inference.signature import BuiltinSignature
|
||||
from jedi.inference.context import AbstractContext
|
||||
from jedi.inference.context import CompiledContext
|
||||
|
||||
|
||||
class CheckAttribute(object):
|
||||
@@ -264,7 +264,7 @@ class CompiledObject(Value):
|
||||
return NO_VALUES
|
||||
|
||||
def _as_context(self):
|
||||
return AbstractContext(self)
|
||||
return CompiledContext(self)
|
||||
|
||||
|
||||
class CompiledName(AbstractNameDefinition):
|
||||
@@ -515,7 +515,9 @@ def _create_from_name(inference_state, compiled_object, name):
|
||||
value = None
|
||||
for access_path in access_paths:
|
||||
value = create_cached_compiled_object(
|
||||
inference_state, access_path, parent_context=value
|
||||
inference_state,
|
||||
access_path,
|
||||
parent_context=None if value is None else value.as_context(),
|
||||
)
|
||||
return value
|
||||
|
||||
|
||||
Reference in New Issue
Block a user