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
|
index = index_context
|
||||||
if isinstance(index_context, Slice):
|
if isinstance(index_context, Slice):
|
||||||
index = index.obj
|
index = index.obj
|
||||||
if isinstance(index, CompiledObject):
|
|
||||||
try:
|
try:
|
||||||
index = index.get_safe_value()
|
method = index.get_safe_value
|
||||||
except ValueError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
index = method(default=None)
|
||||||
|
|
||||||
if type(index) in (float, int, str, unicode, slice, bytes):
|
if type(index) in (float, int, str, unicode, slice, bytes):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -19,8 +19,10 @@ class CompiledValue(ContextWrapper):
|
|||||||
super(CompiledValue, self).__init__(instance)
|
super(CompiledValue, self).__init__(instance)
|
||||||
self._compiled_obj = compiled_obj
|
self._compiled_obj = compiled_obj
|
||||||
|
|
||||||
def get_safe_value(self, *args, **kwargs):
|
def __getattribute__(self, name):
|
||||||
return self._compiled_obj.get_safe_value(*args, **kwargs)
|
if name in ('get_safe_value', 'execute_operation'):
|
||||||
|
return getattr(self._compiled_obj, name)
|
||||||
|
return super(CompiledValue, self).__getattribute__(name)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<%s: %s>' % (self.__class__.__name__, self._compiled_obj)
|
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__()):
|
for i in range(self._index_context.py__len__()):
|
||||||
yield LazyKnownContexts(self._get_getitem_contexts(i).execute_annotation())
|
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():
|
if self._is_homogenous():
|
||||||
return self._get_getitem_contexts(0).execute_annotation()
|
return self._get_getitem_contexts(0).execute_annotation()
|
||||||
|
|
||||||
|
|||||||
@@ -187,8 +187,8 @@ def predefine_names(context, flow_scope, dct):
|
|||||||
|
|
||||||
|
|
||||||
def is_compiled(context):
|
def is_compiled(context):
|
||||||
from jedi.evaluate.compiled import CompiledObject
|
from jedi.evaluate.compiled import CompiledObject, CompiledValue
|
||||||
return isinstance(context, CompiledObject)
|
return isinstance(context, (CompiledObject, CompiledValue))
|
||||||
|
|
||||||
|
|
||||||
def is_string(context):
|
def is_string(context):
|
||||||
|
|||||||
Reference in New Issue
Block a user