forked from VimPlug/jedi
Fix a few issues with the newly defined CompiledValue
This commit is contained in:
@@ -250,11 +250,13 @@ def _getitem(context, index_contexts, contextualized_node):
|
||||
index = index_context
|
||||
if isinstance(index_context, Slice):
|
||||
index = index.obj
|
||||
if isinstance(index, CompiledObject):
|
||||
|
||||
try:
|
||||
index = index.get_safe_value()
|
||||
except ValueError:
|
||||
method = index.get_safe_value
|
||||
except AttributeError:
|
||||
pass
|
||||
else:
|
||||
index = method(default=None)
|
||||
|
||||
if type(index) in (float, int, str, unicode, slice, bytes):
|
||||
try:
|
||||
|
||||
@@ -19,8 +19,10 @@ class CompiledValue(ContextWrapper):
|
||||
super(CompiledValue, self).__init__(instance)
|
||||
self._compiled_obj = compiled_obj
|
||||
|
||||
def get_safe_value(self, *args, **kwargs):
|
||||
return self._compiled_obj.get_safe_value(*args, **kwargs)
|
||||
def __getattribute__(self, name):
|
||||
if name in ('get_safe_value', 'execute_operation'):
|
||||
return getattr(self._compiled_obj, name)
|
||||
return super(CompiledValue, self).__getattribute__(name)
|
||||
|
||||
def __repr__(self):
|
||||
return '<%s: %s>' % (self.__class__.__name__, self._compiled_obj)
|
||||
|
||||
@@ -309,7 +309,7 @@ class Tuple(_ContainerBase):
|
||||
for i in range(self._index_context.py__len__()):
|
||||
yield LazyKnownContexts(self._get_getitem_contexts(i).execute_annotation())
|
||||
|
||||
def py__getitem__(self):
|
||||
def py__getitem__(self, index_context_set, contextualized_node):
|
||||
if self._is_homogenous():
|
||||
return self._get_getitem_contexts(0).execute_annotation()
|
||||
|
||||
|
||||
@@ -187,8 +187,8 @@ def predefine_names(context, flow_scope, dct):
|
||||
|
||||
|
||||
def is_compiled(context):
|
||||
from jedi.evaluate.compiled import CompiledObject
|
||||
return isinstance(context, CompiledObject)
|
||||
from jedi.evaluate.compiled import CompiledObject, CompiledValue
|
||||
return isinstance(context, (CompiledObject, CompiledValue))
|
||||
|
||||
|
||||
def is_string(context):
|
||||
|
||||
Reference in New Issue
Block a user