Don't use original formatting in decisions
Using the original formatting makes yapf non-stable in many cases when
formatting the exact same code.
diff --git a/yapftests/reformatter_basic_test.py b/yapftests/reformatter_basic_test.py
index 54b5585..c6182cc 100644
--- a/yapftests/reformatter_basic_test.py
+++ b/yapftests/reformatter_basic_test.py
@@ -1673,8 +1673,8 @@
if True:
if True:
if True:
- boxes[id_] = np.concatenate(
- (points.min(axis=0), qoints.max(axis=0)))
+ boxes[id_] = np.concatenate((points.min(axis=0),
+ qoints.max(axis=0)))
""")
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@@ -1954,9 +1954,9 @@
code = textwrap.dedent("""\
class _():
- @mock.patch.dict(
- os.environ,
- {'HTTP_' + xsrf._XSRF_TOKEN_HEADER.replace('-', '_'): 'atoken'})
+ @mock.patch.dict(os.environ, {
+ 'HTTP_' + xsrf._XSRF_TOKEN_HEADER.replace('-', '_'): 'atoken'
+ })
def _():
pass
diff --git a/yapftests/reformatter_buganizer_test.py b/yapftests/reformatter_buganizer_test.py
index 01b26e7..2eb2f99 100644
--- a/yapftests/reformatter_buganizer_test.py
+++ b/yapftests/reformatter_buganizer_test.py
@@ -140,8 +140,9 @@
'who': 'allin',
# This is an entry that has a dictionary in it. It's ugly
'something': {
- 'page':
- ['[email protected]', '[email protected]'],
+ 'page': [
+ '[email protected]', '[email protected]'
+ ],
'bug': ['[email protected]'],
'email': ['[email protected]'],
},
diff --git a/yapftests/split_penalty_test.py b/yapftests/split_penalty_test.py
index 00a870e..9f57e15 100644
--- a/yapftests/split_penalty_test.py
+++ b/yapftests/split_penalty_test.py
@@ -191,18 +191,18 @@
tree = self._ParseAndComputePenalties(code)
self._CheckPenalties(tree, [
('[', None),
- ('a', STRONGLY_CONNECTED),
- ('for', STRONGLY_CONNECTED),
+ ('a', None),
+ ('for', 0),
('a', STRONGLY_CONNECTED),
('in', STRONGLY_CONNECTED),
('foo', STRONGLY_CONNECTED),
- ('if', STRONGLY_CONNECTED),
+ ('if', 0),
('a', STRONGLY_CONNECTED),
('.', UNBREAKABLE),
('x', DOTTED_NAME),
('==', STRONGLY_CONNECTED),
('37', STRONGLY_CONNECTED),
- (']', STRONGLY_CONNECTED),
+ (']', None),
])
def testFuncCalls(self):
@@ -211,11 +211,11 @@
self._CheckPenalties(tree, [
('foo', None),
('(', UNBREAKABLE),
- ('1', CONTIGUOUS_LIST),
- (',', CONTIGUOUS_LIST),
- ('2', CONTIGUOUS_LIST),
- (',', CONTIGUOUS_LIST),
- ('3', CONTIGUOUS_LIST),
+ ('1', None),
+ (',', None),
+ ('2', None),
+ (',', None),
+ ('3', None),
(')', VERY_STRONGLY_CONNECTED),
])
@@ -229,11 +229,11 @@
('.', STRONGLY_CONNECTED),
('baz', DOTTED_NAME),
('(', STRONGLY_CONNECTED),
- ('1', CONTIGUOUS_LIST),
- (',', CONTIGUOUS_LIST),
- ('2', CONTIGUOUS_LIST),
- (',', CONTIGUOUS_LIST),
- ('3', CONTIGUOUS_LIST),
+ ('1', None),
+ (',', None),
+ ('2', None),
+ (',', None),
+ ('3', None),
(')', VERY_STRONGLY_CONNECTED),
])