forked from VimPlug/jedi
Fix an issue where a slice is indexed, fixes #1748
This commit is contained in:
@@ -342,6 +342,8 @@ class SequenceLiteralValue(Sequence):
|
|||||||
else:
|
else:
|
||||||
with reraise_getitem_errors(TypeError, KeyError, IndexError):
|
with reraise_getitem_errors(TypeError, KeyError, IndexError):
|
||||||
node = self.get_tree_entries()[index]
|
node = self.get_tree_entries()[index]
|
||||||
|
if node == ':' or node.type == 'subscript':
|
||||||
|
return NO_VALUES
|
||||||
return self._defining_context.infer_node(node)
|
return self._defining_context.infer_node(node)
|
||||||
|
|
||||||
def py__iter__(self, contextualized_node=None):
|
def py__iter__(self, contextualized_node=None):
|
||||||
@@ -407,16 +409,6 @@ class SequenceLiteralValue(Sequence):
|
|||||||
else:
|
else:
|
||||||
return [array_node]
|
return [array_node]
|
||||||
|
|
||||||
def exact_key_items(self):
|
|
||||||
"""
|
|
||||||
Returns a generator of tuples like dict.items(), where the key is
|
|
||||||
resolved (as a string) and the values are still lazy values.
|
|
||||||
"""
|
|
||||||
for key_node, value in self.get_tree_entries():
|
|
||||||
for key in self._defining_context.infer_node(key_node):
|
|
||||||
if is_string(key):
|
|
||||||
yield key.get_safe_value(), LazyTreeValue(self._defining_context, value)
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<%s of %s>" % (self.__class__.__name__, self.atom)
|
return "<%s of %s>" % (self.__class__.__name__, self.atom)
|
||||||
|
|
||||||
@@ -472,6 +464,16 @@ class DictLiteralValue(_DictMixin, SequenceLiteralValue, _DictKeyMixin):
|
|||||||
|
|
||||||
return ValueSet([FakeList(self.inference_state, lazy_values)])
|
return ValueSet([FakeList(self.inference_state, lazy_values)])
|
||||||
|
|
||||||
|
def exact_key_items(self):
|
||||||
|
"""
|
||||||
|
Returns a generator of tuples like dict.items(), where the key is
|
||||||
|
resolved (as a string) and the values are still lazy values.
|
||||||
|
"""
|
||||||
|
for key_node, value in self.get_tree_entries():
|
||||||
|
for key in self._defining_context.infer_node(key_node):
|
||||||
|
if is_string(key):
|
||||||
|
yield key.get_safe_value(), LazyTreeValue(self._defining_context, value)
|
||||||
|
|
||||||
def _dict_values(self):
|
def _dict_values(self):
|
||||||
return ValueSet.from_sets(
|
return ValueSet.from_sets(
|
||||||
self._defining_context.infer_node(v)
|
self._defining_context.infer_node(v)
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ b[int():]
|
|||||||
|
|
||||||
#? list()
|
#? list()
|
||||||
b[:]
|
b[:]
|
||||||
|
#? int()
|
||||||
|
b[:, :-1]
|
||||||
|
|
||||||
#? 3
|
#? 3
|
||||||
b[:]
|
b[:]
|
||||||
@@ -67,6 +69,20 @@ class _StrangeSlice():
|
|||||||
#? slice()
|
#? slice()
|
||||||
_StrangeSlice()[1:2]
|
_StrangeSlice()[1:2]
|
||||||
|
|
||||||
|
for x in b[:]:
|
||||||
|
#? int()
|
||||||
|
x
|
||||||
|
|
||||||
|
for x in b[:, :-1]:
|
||||||
|
#?
|
||||||
|
x
|
||||||
|
|
||||||
|
class Foo:
|
||||||
|
def __getitem__(self, item):
|
||||||
|
return item
|
||||||
|
|
||||||
|
#?
|
||||||
|
Foo()[:, :-1][0]
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# iterable multiplication
|
# iterable multiplication
|
||||||
|
|||||||
Reference in New Issue
Block a user