Add issue 'dict unpacking cannot be used in dict comprehension'

This commit is contained in:
Dave Halter
2017-07-23 23:47:57 +02:00
parent 915b00dab7
commit c2ab9a9e25
2 changed files with 10 additions and 0 deletions

View File

@@ -212,6 +212,15 @@ class ErrorFinder(Normalizer):
if child not in (',', ')') and not child.star_count]
if len(after) == 0:
self._add_syntax_error("named arguments must follow bare *", leaf)
elif leaf.value == '**':
if leaf.parent.type == 'dictorsetmaker':
comp_for = leaf.get_next_sibling().get_next_sibling()
if comp_for is not None and comp_for.type == 'comp_for':
# {**{} for a in [1]}
message = "dict unpacking cannot be used in dict comprehension"
# TODO probably this should get a better end_pos including
# the next sibling of leaf.
self._add_syntax_error(message, leaf)
return ''
def _add_indentation_error(self, message, spacing):