1
0
forked from VimPlug/jedi

Now expr_stmt tuple unpacking automatically works with static analysis.

This commit is contained in:
Dave Halter
2015-11-24 01:07:32 +01:00
parent 8ee42e24a8
commit 724f7111a8
3 changed files with 13 additions and 2 deletions

View File

@@ -444,13 +444,17 @@ def ordered_elements_of_iterable(evaluator, iterable_type, all_values):
def create_for_dict(evaluator, types, exprlist):
"""
Unpacking tuple assignments in for statements and expr_stmts.
"""
if exprlist.type == 'name':
return {exprlist.value: types}
elif exprlist.type == 'atom' and exprlist.children[0] in '([':
return create_for_dict(evaluator, types, exprlist.children[1])
elif exprlist.type in ('testlist_comp', 'exprlist'):
elif exprlist.type in ('testlist', 'testlist_comp', 'exprlist',
'testlist_star_expr'):
dct = {}
parts = iter(exprlist.children[:2])
parts = iter(exprlist.children[::2])
for iter_types in ordered_elements_of_iterable(evaluator, types, []):
try:
part = next(parts)