All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
This makes blib2to3's tree output valid again (which was broken by the previous
fiddling with INDENT and DEDENT nodes).
Fixes #334
* they now correctly work across function/class boundaries (#335)
* 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)
* fixed improper formatting of f-strings with quotes inside interpolated
expressions (#322)
if debug:
self.logger.debug("%s %r (prefix=%r)",
token.tok_name[type], value, prefix)
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
- if type == token.DEDENT:
+ value = ""
+ elif type == token.DEDENT:
_indent_col = indent_columns.pop()
_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 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
if type in {token.INDENT, token.DEDENT}:
prefix = _prefix
lineno, column = end
simple_stmt
expr_stmt
NAME
simple_stmt
expr_stmt
NAME
'tree_depth'
annassign
COLON
'tree_depth'
annassign
COLON
simple_stmt
expr_stmt
NAME
simple_stmt
expr_stmt
NAME
simple_stmt
expr_stmt
NAME
simple_stmt
expr_stmt
NAME
simple_stmt
yield_expr
NAME
simple_stmt
yield_expr
NAME
simple_stmt
expr_stmt
NAME
simple_stmt
expr_stmt
NAME
- "# We don't have to handle prefixes for `Node` objects since\n # that delegates to the first child anyway.\n "
+ " # We don't have to handle prefixes for `Node` objects since\n # that delegates to the first child anyway.\n "
'"""Pretty-prints a given string of `code`.\n\n Convenience method for debugging.\n """'
NEWLINE
'\n'
'"""Pretty-prints a given string of `code`.\n\n Convenience method for debugging.\n """'
NEWLINE
'\n'
pass
def check_fader(test):
pass
def check_fader(test):
+
+ pass
+
+def verify_fader(test):
+ # misaligned comment
+def verify_fader(test):
+ """Hey, ho."""
+ assert test.passed()
+
def test_calculate_fades():
calcs = [
# one is zero/none
def test_calculate_fades():
calcs = [
# one is zero/none