Loading README.md +3 −0 Changes for README.md: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -830,6 +830,9 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md). * they now correctly work across function/class boundaries (#335) * they now work when an indentation block starts with empty lines or misaligned comments (#334) * fixed improper formatting of f-strings with quotes inside interpolated expressions (#322) Loading blib2to3/pgen2/driver.py +6 −11 Changes for blib2to3/pgen2/driver.py: 6 added lines, 11 removed lines. Original line number Diff line number Diff line Loading @@ -70,24 +70,19 @@ def parse_tokens(self, tokens, debug=False): if debug: self.logger.debug("%s %r (prefix=%r)", token.tok_name[type], value, prefix) if type in {token.INDENT, token.DEDENT}: _prefix = prefix if type == token.INDENT: indent_columns.append(len(value)) _prefix = prefix + value prefix = "" if type == token.DEDENT: value = "" elif type == token.DEDENT: _indent_col = indent_columns.pop() prefix, _prefix = self._partially_consume_prefix(_prefix, _indent_col) prefix, _prefix = self._partially_consume_prefix(prefix, _indent_col) if p.addtoken(type, value, (prefix, start)): if debug: self.logger.debug("Stop.") break prefix = "" if type == token.INDENT: indent_columns.append(len(value)) if _prefix.startswith(value): # Don't double-indent. Since we're delaying the prefix that # would normally belong to INDENT, we need to put the value # at the end versus at the beginning. _prefix = _prefix[len(value):] + value if type in {token.INDENT, token.DEDENT}: prefix = _prefix lineno, column = end Loading tests/data/debug_visitor.out +6 −0 Changes for tests/data/debug_visitor.out: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ file_input simple_stmt expr_stmt NAME ' ' 'tree_depth' annassign COLON Loading Loading @@ -113,6 +114,7 @@ file_input simple_stmt expr_stmt NAME ' ' 'indent' EQUAL ' ' Loading Loading @@ -188,6 +190,7 @@ file_input simple_stmt expr_stmt NAME ' ' '_type' EQUAL ' ' Loading Loading @@ -301,6 +304,7 @@ file_input simple_stmt yield_expr NAME ' ' 'yield' yield_arg NAME Loading Loading @@ -414,6 +418,7 @@ file_input simple_stmt expr_stmt NAME ' ' '_type' EQUAL ' ' Loading Loading @@ -702,6 +707,7 @@ file_input '' simple_stmt STRING ' ' '"""Pretty-prints a given string of `code`.\n\n Convenience method for debugging.\n """' NEWLINE '\n' Loading tests/data/fmtonoff2.py +9 −0 Changes for tests/data/fmtonoff2.py: 9 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -19,8 +19,17 @@ def test_fader(test): pass def check_fader(test): pass def verify_fader(test): # misaligned comment pass def verify_fader(test): """Hey, ho.""" assert test.passed() def test_calculate_fades(): calcs = [ # one is zero/none Loading Loading
README.md +3 −0 Changes for README.md: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -830,6 +830,9 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md). * they now correctly work across function/class boundaries (#335) * they now work when an indentation block starts with empty lines or misaligned comments (#334) * fixed improper formatting of f-strings with quotes inside interpolated expressions (#322) Loading
blib2to3/pgen2/driver.py +6 −11 Changes for blib2to3/pgen2/driver.py: 6 added lines, 11 removed lines. Original line number Diff line number Diff line Loading @@ -70,24 +70,19 @@ def parse_tokens(self, tokens, debug=False): if debug: self.logger.debug("%s %r (prefix=%r)", token.tok_name[type], value, prefix) if type in {token.INDENT, token.DEDENT}: _prefix = prefix if type == token.INDENT: indent_columns.append(len(value)) _prefix = prefix + value prefix = "" if type == token.DEDENT: value = "" elif type == token.DEDENT: _indent_col = indent_columns.pop() prefix, _prefix = self._partially_consume_prefix(_prefix, _indent_col) prefix, _prefix = self._partially_consume_prefix(prefix, _indent_col) if p.addtoken(type, value, (prefix, start)): if debug: self.logger.debug("Stop.") break prefix = "" if type == token.INDENT: indent_columns.append(len(value)) if _prefix.startswith(value): # Don't double-indent. Since we're delaying the prefix that # would normally belong to INDENT, we need to put the value # at the end versus at the beginning. _prefix = _prefix[len(value):] + value if type in {token.INDENT, token.DEDENT}: prefix = _prefix lineno, column = end Loading
tests/data/debug_visitor.out +6 −0 Changes for tests/data/debug_visitor.out: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ file_input simple_stmt expr_stmt NAME ' ' 'tree_depth' annassign COLON Loading Loading @@ -113,6 +114,7 @@ file_input simple_stmt expr_stmt NAME ' ' 'indent' EQUAL ' ' Loading Loading @@ -188,6 +190,7 @@ file_input simple_stmt expr_stmt NAME ' ' '_type' EQUAL ' ' Loading Loading @@ -301,6 +304,7 @@ file_input simple_stmt yield_expr NAME ' ' 'yield' yield_arg NAME Loading Loading @@ -414,6 +418,7 @@ file_input simple_stmt expr_stmt NAME ' ' '_type' EQUAL ' ' Loading Loading @@ -702,6 +707,7 @@ file_input '' simple_stmt STRING ' ' '"""Pretty-prints a given string of `code`.\n\n Convenience method for debugging.\n """' NEWLINE '\n' Loading
tests/data/fmtonoff2.py +9 −0 Changes for tests/data/fmtonoff2.py: 9 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -19,8 +19,17 @@ def test_fader(test): pass def check_fader(test): pass def verify_fader(test): # misaligned comment pass def verify_fader(test): """Hey, ho.""" assert test.passed() def test_calculate_fades(): calcs = [ # one is zero/none Loading