pyminifier
pyminifier copied to clipboard
Indentation issue after removing docstrings
Very simple example with the following file:
class MyClass(object):
first_variable = 42
"""Second variable docstring."""
_second_variable = 'foo'
The result of the minification is:
class MyClass(object):
first_variable=42
_second_variable='foo'
The second variable is not indented correctly: there's an extra space. So the minified code doesn't compile.
I think I found the reason: in the file minification.py, line 94, the removal of the training newline seems to mess up the line numbers, and the rebuilding of the text from the tokens in token_utils.py / untokenize produces the wrong output. Commenting out line 94 in minification.py seems to solve the problem. This will probably leave an unneeded empty line in the text, but it will be removed afterwards anyway, so no big deal, I guess.