Encompass the dictionary value in pseudo parens
If a dictionary's value has a comment before it, then we want to include the
value within the pseudo parens. Otherwise only the comment is seen as being
part of the dictionary's value.
diff --git a/yapftests/reformatter_buganizer_test.py b/yapftests/reformatter_buganizer_test.py
index fcf2be9..7173154 100644
--- a/yapftests/reformatter_buganizer_test.py
+++ b/yapftests/reformatter_buganizer_test.py
@@ -28,6 +28,23 @@
def setUpClass(cls):
style.SetGlobalStyle(style.CreateChromiumStyle())
+ def testB32737279(self):
+ unformatted_code = textwrap.dedent("""\
+ here_is_a_dict = {
+ 'key':
+ # Comment.
+ 'value'
+ }
+ """)
+ expected_formatted_code = textwrap.dedent("""\
+ here_is_a_dict = {
+ 'key': # Comment.
+ 'value'
+ }
+ """)
+ uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+
def testB32570937(self):
code = textwrap.dedent("""\
def _():