Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pyminifier/minification.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ def foo(foo,bar,blah):
last_col = 0
if token_type != tokenize.OP:
if start_col > last_col and token_type not in nl_types:
if prev_tok[0] != tokenize.OP:
if prev_tok and prev_tok[0] != tokenize.OP:
out += (" " * (start_col - last_col))
if token_type == tokenize.STRING:
if prev_tok[0] == tokenize.STRING:
if prev_tok and prev_tok[0] == tokenize.STRING:
# Join the strings into one
string_type = token_string[0] # '' or ""
prev_string_type = prev_tok[1][0]
Expand All @@ -215,15 +215,15 @@ def foo(foo,bar,blah):
new_string += token_string.strip(string_type)
else:
if token_string in ('}', ')', ']'):
if prev_tok[1] == ',':
if prev_tok and prev_tok[1] == ',':
out = out.rstrip(',')
if joining_strings:
# NOTE: Using triple quotes so that this logic works with
# mixed strings using both single quotes and double quotes.
out += "'''" + new_string + "'''"
joining_strings = False
if token_string == '@': # Decorators need special handling
if prev_tok[0] == tokenize.NEWLINE:
if prev_tok and prev_tok[0] == tokenize.NEWLINE:
# Ensure it gets indented properly
out += (" " * (start_col - last_col))
if not joining_strings:
Expand Down