forked from VimPlug/jedi
Fix an issue with slice indexing.
This commit is contained in:
@@ -378,7 +378,7 @@ class Evaluator(object):
|
||||
pass
|
||||
else:
|
||||
if comp_for == ':':
|
||||
# Dict comprehensions have it at the 3rd index.
|
||||
# Dict comprehensions have a colon at the 3rd index.
|
||||
try:
|
||||
comp_for = c[1].children[3]
|
||||
except IndexError:
|
||||
|
||||
@@ -821,7 +821,11 @@ def create_index_types(evaluator, index):
|
||||
"""
|
||||
Handles slices in subscript nodes.
|
||||
"""
|
||||
if tree.is_node(index, 'subscript'): # subscript is a slice operation.
|
||||
if index == ':':
|
||||
# Like array[:]
|
||||
return set([Slice(evaluator, None, None, None)])
|
||||
elif tree.is_node(index, 'subscript'): # subscript is a slice operation.
|
||||
# Like array[:3]
|
||||
result = []
|
||||
for el in index.children:
|
||||
if el == ':':
|
||||
@@ -835,4 +839,6 @@ def create_index_types(evaluator, index):
|
||||
result += [None] * (3 - len(result))
|
||||
|
||||
return set([Slice(evaluator, *result)])
|
||||
|
||||
# No slices
|
||||
return evaluator.eval_element(index)
|
||||
|
||||
@@ -39,6 +39,9 @@ b[8:]
|
||||
#? list()
|
||||
b[int():]
|
||||
|
||||
#? list()
|
||||
b[:]
|
||||
|
||||
|
||||
class _StrangeSlice():
|
||||
def __getitem__(self, sliced):
|
||||
|
||||
Reference in New Issue
Block a user