1
0
forked from VimPlug/jedi

also remove crashes with pep 448 unpacking of lists and sets

This commit is contained in:
Claude
2018-09-22 23:29:13 +02:00
committed by Dave Halter
parent 6bc79b4933
commit a2b984ce24
2 changed files with 42 additions and 5 deletions

View File

@@ -346,7 +346,9 @@ class SequenceLiteralContext(Sequence):
return [] # Direct closing bracket, doesn't contain items.
if array_node.type == 'testlist_comp':
return array_node.children[::2]
# filter out (for now) pep 448 single-star unpacking
return [value for value in array_node.children[::2]
if value.type != "star_expr"]
elif array_node.type == 'dictorsetmaker':
kv = []
iterator = iter(array_node.children)
@@ -359,14 +361,24 @@ class SequenceLiteralContext(Sequence):
else:
op = next(iterator, None)
if op is None or op == ',':
kv.append(key) # A set.
if key.type == "star_expr":
# pep 448 single-star unpacking
# for now ignoring values imported by *
pass
else:
kv.append(key) # A set.
else:
assert op == ':' # A dict.
kv.append((key, next(iterator)))
next(iterator, None) # Possible comma.
return kv
else:
return [array_node]
if array_node.type == "star_expr":
# pep 448 single-star unpacking
# for now ignoring values imported by *
return []
else:
return [array_node]
def exact_key_items(self):
"""