def/class keywords after an opening parentheses led to empty arrays without closing brackets, tests & fixes #416

This commit is contained in:
Dave Halter
2014-07-18 12:53:06 +02:00
parent 3be5220bf1
commit 0dea47b260
2 changed files with 14 additions and 1 deletions

View File

@@ -1023,7 +1023,11 @@ isinstance(c, (tokenize.Token, Operator)) else unicode(c)
# always dictionaries and not sets. # always dictionaries and not sets.
arr.type = Array.DICT arr.type = Array.DICT
arr.end_pos = (break_tok or stmt or old_stmt).end_pos try:
arr.end_pos = (break_tok or stmt or old_stmt).end_pos
except UnboundLocalError:
# In case of something like `(def`
arr.end_pos = start_pos[0], start_pos[1] + 1
return arr, break_tok return arr, break_tok
def parse_stmt(token_iterator, maybe_dict=False, added_breaks=(), def parse_stmt(token_iterator, maybe_dict=False, added_breaks=(),

View File

@@ -25,3 +25,12 @@ IndentIssues().one_param()
#? str() #? str()
IndentIssues().with_param('') IndentIssues().with_param('')
"""
Just because there's a def keyword, doesn't mean it should not be able to
complete to definition.
"""
definition = 0
#? ['definition', 'def']
str(def