aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2021-12-25 00:14:19 -0600
committerBill Wendling <isanbard@gmail.com>2021-12-25 00:14:19 -0600
commitcc7770bb3c5cfec82a8805a057e0d10b23d274c8 (patch)
tree208a588e3aa52d3e32ff394f67990aeae10f3b56
parent76b039c125fc437547db45123d8bc275b073ef32 (diff)
downloadyapf-cc7770bb3c5cfec82a8805a057e0d10b23d274c8.tar.gz
Add "splitpenalty" to the format_token repr
-rw-r--r--yapf/yapflib/format_token.py7
-rw-r--r--yapftests/format_token_test.py8
2 files changed, 8 insertions, 7 deletions
diff --git a/yapf/yapflib/format_token.py b/yapf/yapflib/format_token.py
index 1f3f73e..af31d32 100644
--- a/yapf/yapflib/format_token.py
+++ b/yapf/yapflib/format_token.py
@@ -216,9 +216,10 @@ class FormatToken(object):
return self.value in pytree_utils.CLOSING_BRACKETS
def __repr__(self):
- msg = 'FormatToken(name={0}, value={1}, column={2}, lineno={3}'.format(
- 'DOCSTRING' if self.is_docstring else self.name, self.value,
- self.column, self.lineno)
+ msg = ('FormatToken(name={0}, value={1}, column={2}, lineno={3}, '
+ 'splitpenalty={4}'.format(
+ 'DOCSTRING' if self.is_docstring else self.name, self.value,
+ self.column, self.lineno, self.split_penalty))
msg += ', pseudo)' if self.is_pseudo else ')'
return msg
diff --git a/yapftests/format_token_test.py b/yapftests/format_token_test.py
index 8c7151a..e324983 100644
--- a/yapftests/format_token_test.py
+++ b/yapftests/format_token_test.py
@@ -68,14 +68,14 @@ class FormatTokenTest(unittest.TestCase):
def testSimple(self):
tok = format_token.FormatToken(pytree.Leaf(token.STRING, "'hello world'"))
self.assertEqual(
- "FormatToken(name=DOCSTRING, value='hello world', column=0, lineno=0)",
- str(tok))
+ "FormatToken(name=DOCSTRING, value='hello world', column=0, "
+ "lineno=0, splitpenalty=0)", str(tok))
self.assertTrue(tok.is_string)
tok = format_token.FormatToken(pytree.Leaf(token.COMMENT, '# A comment'))
self.assertEqual(
- 'FormatToken(name=COMMENT, value=# A comment, column=0, lineno=0)',
- str(tok))
+ 'FormatToken(name=COMMENT, value=# A comment, column=0, '
+ 'lineno=0, splitpenalty=0)', str(tok))
self.assertTrue(tok.is_comment)
def testIsMultilineString(self):