@@ -196,10 +196,10 @@ def foo(foo,bar,blah):
196196 last_col = 0
197197 if token_type != tokenize .OP :
198198 if start_col > last_col and token_type not in nl_types :
199- if prev_tok [0 ] != tokenize .OP :
199+ if prev_tok and prev_tok [0 ] != tokenize .OP :
200200 out += (" " * (start_col - last_col ))
201201 if token_type == tokenize .STRING :
202- if prev_tok [0 ] == tokenize .STRING :
202+ if prev_tok and prev_tok [0 ] == tokenize .STRING :
203203 # Join the strings into one
204204 string_type = token_string [0 ] # '' or ""
205205 prev_string_type = prev_tok [1 ][0 ]
@@ -215,15 +215,15 @@ def foo(foo,bar,blah):
215215 new_string += token_string .strip (string_type )
216216 else :
217217 if token_string in ('}' , ')' , ']' ):
218- if prev_tok [1 ] == ',' :
218+ if prev_tok and prev_tok [1 ] == ',' :
219219 out = out .rstrip (',' )
220220 if joining_strings :
221221 # NOTE: Using triple quotes so that this logic works with
222222 # mixed strings using both single quotes and double quotes.
223223 out += "'''" + new_string + "'''"
224224 joining_strings = False
225225 if token_string == '@' : # Decorators need special handling
226- if prev_tok [0 ] == tokenize .NEWLINE :
226+ if prev_tok and prev_tok [0 ] == tokenize .NEWLINE :
227227 # Ensure it gets indented properly
228228 out += (" " * (start_col - last_col ))
229229 if not joining_strings :
0 commit comments