Show More
@@ -644,6 +644,18 b' class TransformerManager:' | |||||
644 |
|
644 | |||
645 | newline_types = {tokenize.NEWLINE, tokenize.COMMENT, tokenize.ENDMARKER} |
|
645 | newline_types = {tokenize.NEWLINE, tokenize.COMMENT, tokenize.ENDMARKER} | |
646 |
|
646 | |||
|
647 | # Convert if using cpython tokenize | |||
|
648 | if (list(map(lambda x: x.type, tokens_by_line[-1])) == | |||
|
649 | [tokenize.DEDENT] * (len(tokens_by_line[-1]) - 1) + [tokenize.ENDMARKER]): | |||
|
650 | if ( | |||
|
651 | len(tokens_by_line) > 1 and | |||
|
652 | len(tokens_by_line[-2]) > 0 and | |||
|
653 | tokens_by_line[-2][-1].type == tokenize.NEWLINE | |||
|
654 | ): | |||
|
655 | tokens_by_line[-2].pop() | |||
|
656 | tokens_by_line[-2] += tokens_by_line[-1] | |||
|
657 | tokens_by_line.pop() | |||
|
658 | ||||
647 | # Remove newline_types for the list of tokens |
|
659 | # Remove newline_types for the list of tokens | |
648 | while len(tokens_by_line) > 1 and len(tokens_by_line[-1]) == 1 \ |
|
660 | while len(tokens_by_line) > 1 and len(tokens_by_line[-1]) == 1 \ | |
649 | and tokens_by_line[-1][-1].type in newline_types: |
|
661 | and tokens_by_line[-1][-1].type in newline_types: |
General Comments 0
You need to be logged in to leave comments.
Login now