Show More
@@ -643,25 +643,23 b' class TransformerManager:' | |||
|
643 | 643 | and tokens_by_line[-1][-1].type in newline_types: |
|
644 | 644 | tokens_by_line.pop() |
|
645 | 645 | |
|
646 | last_line_token = tokens_by_line[-1] | |
|
647 | 646 | |
|
648 | while tokens_by_line[-1][-1].type in newline_types: | |
|
649 |
|
|
|
647 | while tokens_by_line[-1] and tokens_by_line[-1][-1].type in newline_types: | |
|
648 | tokens_by_line[-1].pop() | |
|
650 | 649 | |
|
651 |
if len( |
|
|
650 | if len(tokens_by_line) == 1 and not tokens_by_line[-1]: | |
|
652 | 651 | return 'incomplete', 0 |
|
653 | 652 | |
|
654 |
if |
|
|
653 | if tokens_by_line[-1][-1].string == ':': | |
|
655 | 654 | # The last line starts a block (e.g. 'if foo:') |
|
656 | 655 | ix = 0 |
|
657 | while last_line_token[ix].type \ | |
|
658 | in {tokenize.INDENT, tokenize.DEDENT}: | |
|
656 | while tokens_by_line[-1][ix].type in {tokenize.INDENT, tokenize.DEDENT}: | |
|
659 | 657 | ix += 1 |
|
660 | 658 | |
|
661 |
indent = |
|
|
659 | indent = tokens_by_line[-1][ix].start[1] | |
|
662 | 660 | return 'incomplete', indent + 4 |
|
663 | 661 | |
|
664 |
if |
|
|
662 | if tokens_by_line[-1][0].line.endswith('\\'): | |
|
665 | 663 | return 'incomplete', None |
|
666 | 664 | |
|
667 | 665 | # At this point, our checks think the code is complete (or invalid). |
@@ -677,14 +675,18 b' class TransformerManager:' | |||
|
677 | 675 | if res is None: |
|
678 | 676 | return 'incomplete', find_last_indent(lines) |
|
679 | 677 | |
|
680 |
if |
|
|
678 | if tokens_by_line[-1][-1].type == tokenize.DEDENT: | |
|
681 | 679 | if ends_with_newline: |
|
682 | 680 | return 'complete', None |
|
683 | 681 | return 'incomplete', find_last_indent(lines) |
|
684 | 682 | |
|
685 |
if len( |
|
|
683 | if len(tokens_by_line[-1]) <= 1: | |
|
686 | 684 | return 'incomplete', find_last_indent(lines) |
|
687 | 685 | |
|
686 | # If there's a blank line at the end, assume we're ready to execute | |
|
687 | if not lines[-1].strip(): | |
|
688 | return 'complete', None | |
|
689 | ||
|
688 | 690 | return 'complete', None |
|
689 | 691 | |
|
690 | 692 |
General Comments 0
You need to be logged in to leave comments.
Login now