content: # Copyright 2016 Google Inc. All Rights Reserved.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  """Buganizer tests for yapf.reformatter."""
  
  import textwrap
  import unittest
  
  from yapf.yapflib import reformatter
  from yapf.yapflib import style
  
  from yapftests import yapf_test_helper
  
  
  class BuganizerFixes(yapf_test_helper.YAPFTest):
  
    @classmethod
    def setUpClass(cls):
      style.SetGlobalStyle(style.CreateYapfStyle())
  
    def testB137580392(self):
      code = textwrap.dedent("""\
          def _create_testing_simulator_and_sink(
          ) -> Tuple[_batch_simulator:_batch_simulator.BatchSimulator,
                     _batch_simulator.SimulationSink]:
            pass
      """)
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB73279849(self):
      unformatted_code = textwrap.dedent("""\
          class A:
              def _(a):
                  return 'hello'  [  a  ]
      """)
      expected_formatted_code = textwrap.dedent("""\
          class A:
            def _(a):
              return 'hello'[a]
      """)
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB122455211(self):
      unformatted_code = textwrap.dedent("""\
          _zzzzzzzzzzzzzzzzzzzz = Union[sssssssssssssssssssss.pppppppppppppppp,
                               sssssssssssssssssssss.pppppppppppppppppppppppppppp]
      """)  # noqa
      expected_formatted_code = textwrap.dedent("""\
          _zzzzzzzzzzzzzzzzzzzz = Union[
              sssssssssssssssssssss.pppppppppppppppp,
              sssssssssssssssssssss.pppppppppppppppppppppppppppp]
      """)
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB119300344(self):
      code = textwrap.dedent("""\
          def _GenerateStatsEntries(
              process_id: Text,
              timestamp: Optional[rdfvalue.RDFDatetime] = None
          ) -> Sequence[stats_values.StatsStoreEntry]:
            pass
      """)
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB132886019(self):
      code = textwrap.dedent("""\
          X = {
              'some_dict_key':
                  frozenset([
                      # pylint: disable=line-too-long
                      '//this/path/is/really/too/long/for/this/line/and/probably/should/be/split',
                  ]),
          }
      """)
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB26521719(self):
      code = textwrap.dedent("""\
          class _():
  
            def _(self):
              self.stubs.Set(some_type_of_arg, 'ThisIsAStringArgument',
                             lambda *unused_args, **unused_kwargs: fake_resolver)
      """)
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB122541552(self):
      code = textwrap.dedent("""\
          # pylint: disable=g-explicit-bool-comparison,singleton-comparison
          _QUERY = account.Account.query(account.Account.enabled == True)
          # pylint: enable=g-explicit-bool-comparison,singleton-comparison
  
  
          def _():
            pass
      """)
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB124415889(self):
      code = textwrap.dedent("""\
          class _():
  
            def run_queue_scanners():
              return xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(
                  {
                      components.NAME.FNOR: True,
                      components.NAME.DEVO: True,
                  },
                  default=False)
  
            def modules_to_install():
              modules = DeepCopy(GetDef({}))
              modules.update({
                  'xxxxxxxxxxxxxxxxxxxx':
                      GetDef('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', None),
              })
              return modules
      """)
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB73166511(self):
      code = textwrap.dedent("""\
          def _():
            if min_std is not None:
              groundtruth_age_variances = tf.maximum(groundtruth_age_variances,
                                                     min_std**2)
      """)
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB118624921(self):
      code = textwrap.dedent("""\
          def _():
            function_call(
                alert_name='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
                time_delta='1h',
                alert_level='bbbbbbbb',
                metric='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
                bork=foo)
      """)  # noqa
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB35417079(self):
      code = textwrap.dedent("""\
          class _():
  
            def _():
              X = (
                  _ares_label_prefix +
                  'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'  # pylint: disable=line-too-long
                  'PyTypePyTypePyTypePyTypePyTypePyTypePyTypePyTypePyTypePyTypePyTypePyTypePyType'  # pytype: disable=attribute-error
                  'CopybaraCopybaraCopybaraCopybaraCopybaraCopybaraCopybaraCopybaraCopybara'  # copybara:strip
              )
      """)  # noqa
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB120047670(self):
      unformatted_code = textwrap.dedent("""\
          X = {
              'NO_PING_COMPONENTS': [
                  79775,          # Releases / FOO API
                  79770,          # Releases / BAZ API
                  79780],         # Releases / MUX API
  
              'PING_BLOCKED_BUGS': False,
          }
      """)
      expected_formatted_code = textwrap.dedent("""\
          X = {
              'NO_PING_COMPONENTS': [
                  79775,  # Releases / FOO API
                  79770,  # Releases / BAZ API
                  79780
              ],  # Releases / MUX API
              'PING_BLOCKED_BUGS': False,
          }
      """)
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB120245013(self):
      unformatted_code = textwrap.dedent("""\
          class Foo(object):
            def testNoAlertForShortPeriod(self, rutabaga):
              self.targets[:][streamz_path,self._fillInOtherFields(streamz_path, {streamz_field_of_interest:True})] = series.Counter('1s', '+ 500x10000')
      """)  # noqa
      expected_formatted_code = textwrap.dedent("""\
          class Foo(object):
  
            def testNoAlertForShortPeriod(self, rutabaga):
              self.targets[:][
                  streamz_path,
                  self._fillInOtherFields(streamz_path, {streamz_field_of_interest: True}
                                         )] = series.Counter('1s', '+ 500x10000')
      """)  # noqa
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB117841880(self):
      code = textwrap.dedent("""\
          def xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(
              aaaaaaaaaaaaaaaaaaa: AnyStr,
              bbbbbbbbbbbb: Optional[Sequence[AnyStr]] = None,
              cccccccccc: AnyStr = cst.DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD,
              dddddddddd: Sequence[SliceDimension] = (),
              eeeeeeeeeeee: AnyStr = cst.DEFAULT_CONTROL_NAME,
              ffffffffffffffffffff: Optional[Callable[[pd.DataFrame],
                                                      pd.DataFrame]] = None,
              gggggggggggggg: ooooooooooooo = ooooooooooooo()
          ) -> pd.DataFrame:
            pass
      """)
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB111764402(self):
      unformatted_code = textwrap.dedent("""\
          x = self.stubs.stub(video_classification_map,              'read_video_classifications',       (lambda external_ids, **unused_kwargs:                     {external_id: self._get_serving_classification('video') for external_id in external_ids}))
      """)  # noqa
      expected_formatted_code = textwrap.dedent("""\
          x = self.stubs.stub(video_classification_map, 'read_video_classifications',
                              (lambda external_ids, **unused_kwargs: {
                                  external_id: self._get_serving_classification('video')
                                  for external_id in external_ids
                              }))
      """)  # noqa
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB116825060(self):
      code = textwrap.dedent("""\
          result_df = pd.DataFrame({LEARNED_CTR_COLUMN: learned_ctr},
                                   index=df_metrics.index)
      """)
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB112711217(self):
      code = textwrap.dedent("""\
          def _():
            stats['moderated'] = ~stats.moderation_reason.isin(
                approved_moderation_reasons)
      """)
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB112867548(self):
      unformatted_code = textwrap.dedent("""\
          def _():
            return flask.make_response(
                'Records: {}, Problems: {}, More: {}'.format(
                    process_result.result_ct, process_result.problem_ct,
                    process_result.has_more),
                httplib.ACCEPTED if process_result.has_more else httplib.OK,
                {'content-type': _TEXT_CONTEXT_TYPE})
      """)
      expected_formatted_code = textwrap.dedent("""\
          def _():
            return flask.make_response(
                'Records: {}, Problems: {}, More: {}'.format(process_result.result_ct,
                                                             process_result.problem_ct,
                                                             process_result.has_more),
                httplib.ACCEPTED if process_result.has_more else httplib.OK,
                {'content-type': _TEXT_CONTEXT_TYPE})
      """)  # noqa
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB112651423(self):
      unformatted_code = textwrap.dedent("""\
          def potato(feeditems, browse_use_case=None):
            for item in turnip:
              if kumquat:
                if not feeds_variants.variants['FEEDS_LOAD_PLAYLIST_VIDEOS_FOR_ALL_ITEMS'] and item.video:
                  continue
      """)  # noqa
      expected_formatted_code = textwrap.dedent("""\
          def potato(feeditems, browse_use_case=None):
            for item in turnip:
              if kumquat:
                if not feeds_variants.variants[
                    'FEEDS_LOAD_PLAYLIST_VIDEOS_FOR_ALL_ITEMS'] and item.video:
                  continue
      """)
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB80484938(self):
      code = textwrap.dedent("""\
          for sssssss, aaaaaaaaaa in [
              ('ssssssssssssssssssss', 'sssssssssssssssssssssssss'),
              ('nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn',
               'nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn'),
              ('pppppppppppppppppppppppppppp', 'pppppppppppppppppppppppppppppppp'),
              ('wwwwwwwwwwwwwwwwwwww', 'wwwwwwwwwwwwwwwwwwwwwwwww'),
              ('sssssssssssssssss', 'sssssssssssssssssssssss'),
              ('ggggggggggggggggggggggg', 'gggggggggggggggggggggggggggg'),
              ('ggggggggggggggggg', 'gggggggggggggggggggggg'),
              ('eeeeeeeeeeeeeeeeeeeeee', 'eeeeeeeeeeeeeeeeeeeeeeeeeee')
          ]:
            pass
  
          for sssssss, aaaaaaaaaa in [
              ('ssssssssssssssssssss', 'sssssssssssssssssssssssss'),
              ('nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn', 'nnnnnnnnnnnnnnnnnnnnnnnnn'),
              ('pppppppppppppppppppppppppppp', 'pppppppppppppppppppppppppppppppp'),
              ('wwwwwwwwwwwwwwwwwwww', 'wwwwwwwwwwwwwwwwwwwwwwwww'),
              ('sssssssssssssssss', 'sssssssssssssssssssssss'),
              ('ggggggggggggggggggggggg', 'gggggggggggggggggggggggggggg'),
              ('ggggggggggggggggg', 'gggggggggggggggggggggg'),
              ('eeeeeeeeeeeeeeeeeeeeee', 'eeeeeeeeeeeeeeeeeeeeeeeeeee')
          ]:
            pass
  
          for sssssss, aaaaaaaaaa in [
              ('ssssssssssssssssssss', 'sssssssssssssssssssssssss'),
              ('nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn',
               'nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn'),
              ('pppppppppppppppppppppppppppp', 'pppppppppppppppppppppppppppppppp'),
              ('wwwwwwwwwwwwwwwwwwww', 'wwwwwwwwwwwwwwwwwwwwwwwww'),
              ('sssssssssssssssss', 'sssssssssssssssssssssss'),
              ('ggggggggggggggggggggggg', 'gggggggggggggggggggggggggggg'),
              ('ggggggggggggggggg', 'gggggggggggggggggggggg'),
              ('eeeeeeeeeeeeeeeeeeeeee', 'eeeeeeeeeeeeeeeeeeeeeeeeeee'),
          ]:
            pass
      """)  # noqa
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB120771563(self):
      code = textwrap.dedent("""\
          class A:
  
            def b():
              d = {
                  "123456": [{
                      "12": "aa"
                  }, {
                      "12": "bb"
                  }, {
                      "12": "cc",
                      "1234567890": {
                          "1234567": [{
                              "12": "dd",
                              "12345": "text 1"
                          }, {
                              "12": "ee",
                              "12345": "text 2"
                          }]
                      }
                  }]
              }
      """)
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB79462249(self):
      code = textwrap.dedent("""\
          foo.bar(baz, [
              quux(thud=42),
              norf,
          ])
          foo.bar(baz, [
              quux(),
              norf,
          ])
          foo.bar(baz, quux(thud=42), aaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbb,
                  ccccccccccccccccccc)
          foo.bar(
              baz,
              quux(thud=42),
              aaaaaaaaaaaaaaaaaaaaaa=1,
              bbbbbbbbbbbbbbbbbbbbb=2,
              ccccccccccccccccccc=3)
      """)  # noqa
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB113210278(self):
      unformatted_code = textwrap.dedent("""\
          def _():
            aaaaaaaaaaa = bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.cccccccccccccccccccccccccccc(\
          eeeeeeeeeeeeeeeeeeeeeeeeee.fffffffffffffffffffffffffffffffffffffff.\
          ggggggggggggggggggggggggggggggggg.hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh())
      """)  # noqa
      expected_formatted_code = textwrap.dedent("""\
          def _():
            aaaaaaaaaaa = bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.cccccccccccccccccccccccccccc(
                eeeeeeeeeeeeeeeeeeeeeeeeee.fffffffffffffffffffffffffffffffffffffff
                .ggggggggggggggggggggggggggggggggg.hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh())
      """)  # noqa
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB77923341(self):
      code = textwrap.dedent("""\
          def f():
            if (aaaaaaaaaaaaaa.bbbbbbbbbbbb.ccccc <= 0 and  # pytype: disable=attribute-error
                ddddddddddd.eeeeeeeee == constants.FFFFFFFFFFFFFF):
              raise "yo"
      """)  # noqa
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB77329955(self):
      code = textwrap.dedent("""\
          class _():
  
            @parameterized.named_parameters(
                ('ReadyExpiredSuccess', True, True, True, None, None),
                ('SpannerUpdateFails', True, False, True, None, None),
                ('ReadyNotExpired', False, True, True, True, None),
                # ('ReadyNotExpiredNotHealthy', False, True, True, False, True),
                # ('ReadyNotExpiredNotHealthyErrorFails', False, True, True, False, False
                # ('ReadyNotExpiredNotHealthyUpdateFails', False, False, True, False, True
            )
            def _():
              pass
      """)  # noqa
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB65197969(self):
      unformatted_code = textwrap.dedent("""\
          class _():
  
            def _():
              return timedelta(seconds=max(float(time_scale), small_interval) *
                             1.41 ** min(num_attempts, 9))
      """)
      expected_formatted_code = textwrap.dedent("""\
          class _():
  
            def _():
              return timedelta(
                  seconds=max(float(time_scale), small_interval) *
                  1.41**min(num_attempts, 9))
      """)
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB65546221(self):
      unformatted_code = textwrap.dedent("""\
          SUPPORTED_PLATFORMS = (
              "centos-6",
              "centos-7",
              "ubuntu-1204-precise",
              "ubuntu-1404-trusty",
              "ubuntu-1604-xenial",
              "debian-7-wheezy",
              "debian-8-jessie",
              "debian-9-stretch",)
      """)
      expected_formatted_code = textwrap.dedent("""\
          SUPPORTED_PLATFORMS = (
              "centos-6",
              "centos-7",
              "ubuntu-1204-precise",
              "ubuntu-1404-trusty",
              "ubuntu-1604-xenial",
              "debian-7-wheezy",
              "debian-8-jessie",
              "debian-9-stretch",
          )
      """)
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB30500455(self):
      unformatted_code = textwrap.dedent("""\
          INITIAL_SYMTAB = dict([(name, 'exception#' + name) for name in INITIAL_EXCEPTIONS
          ] * [(name, 'type#' + name) for name in INITIAL_TYPES] + [
              (name, 'function#' + name) for name in INITIAL_FUNCTIONS
          ] + [(name, 'const#' + name) for name in INITIAL_CONSTS])
      """)  # noqa
      expected_formatted_code = textwrap.dedent("""\
          INITIAL_SYMTAB = dict(
              [(name, 'exception#' + name) for name in INITIAL_EXCEPTIONS] *
              [(name, 'type#' + name) for name in INITIAL_TYPES] +
              [(name, 'function#' + name) for name in INITIAL_FUNCTIONS] +
              [(name, 'const#' + name) for name in INITIAL_CONSTS])
      """)
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB38343525(self):
      code = textwrap.dedent("""\
          # This does foo.
          @arg.String('some_path_to_a_file', required=True)
          # This does bar.
          @arg.String('some_path_to_a_file', required=True)
          def f():
            print(1)
      """)
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB37099651(self):
      unformatted_code = textwrap.dedent("""\
          _MEMCACHE = lazy.MakeLazy(
              # pylint: disable=g-long-lambda
              lambda: function.call.mem.clients(FLAGS.some_flag_thingy, default_namespace=_LAZY_MEM_NAMESPACE, allow_pickle=True)
              # pylint: enable=g-long-lambda
          )
      """)  # noqa
      expected_formatted_code = textwrap.dedent("""\
          _MEMCACHE = lazy.MakeLazy(
              # pylint: disable=g-long-lambda
              lambda: function.call.mem.clients(
                  FLAGS.some_flag_thingy,
                  default_namespace=_LAZY_MEM_NAMESPACE,
                  allow_pickle=True)
              # pylint: enable=g-long-lambda
          )
      """)
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB33228502(self):
      unformatted_code = textwrap.dedent("""\
          def _():
            success_rate_stream_table = module.Precompute(
                query_function=module.DefineQueryFunction(
                    name='Response error ratio',
                    expression=((m.Fetch(
                            m.Raw('monarch.BorgTask',
                                  '/corp/travel/trips2/dispatcher/email/response'),
                            {'borg_job': module_config.job, 'metric:response_type': 'SUCCESS'}),
                         m.Fetch(m.Raw('monarch.BorgTask', '/corp/travel/trips2/dispatcher/email/response'), {'borg_job': module_config.job}))
                        | m.Window(m.Delta('1h'))
                        | m.Join('successes', 'total')
                        | m.Point(m.VAL['successes'] / m.VAL['total']))))
      """)  # noqa
      expected_formatted_code = textwrap.dedent("""\
          def _():
            success_rate_stream_table = module.Precompute(
                query_function=module.DefineQueryFunction(
                    name='Response error ratio',
                    expression=(
                        (m.Fetch(
                            m.Raw('monarch.BorgTask',
                                  '/corp/travel/trips2/dispatcher/email/response'), {
                                      'borg_job': module_config.job,
                                      'metric:response_type': 'SUCCESS'
                                  }),
                         m.Fetch(
                             m.Raw('monarch.BorgTask',
                                   '/corp/travel/trips2/dispatcher/email/response'),
                             {'borg_job': module_config.job}))
                        | m.Window(m.Delta('1h'))
                        | m.Join('successes', 'total')
                        | m.Point(m.VAL['successes'] / m.VAL['total']))))
      """)  # noqa
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB30394228(self):
      code = textwrap.dedent("""\
          class _():
  
            def _(self):
              return some.randome.function.calling(
                  wf, None, alert.Format(alert.subject, alert=alert, threshold=threshold),
                  alert.Format(alert.body, alert=alert, threshold=threshold),
                  alert.html_formatting)
      """)  # noqa
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB65246454(self):
      unformatted_code = textwrap.dedent("""\
          class _():
  
            def _(self):
              self.assertEqual({i.id
                                for i in successful_instances},
                               {i.id
                                for i in self._statuses.successful_instances})
      """)  # noqa
      expected_formatted_code = textwrap.dedent("""\
          class _():
  
            def _(self):
              self.assertEqual({i.id for i in successful_instances},
                               {i.id for i in self._statuses.successful_instances})
      """)  # noqa
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB67935450(self):
      unformatted_code = textwrap.dedent("""\
          def _():
            return (
                (Gauge(
                    metric='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
                    group_by=group_by + ['metric:process_name'],
                    metric_filter={'metric:process_name': process_name_re}),
                 Gauge(
                     metric='bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
                     group_by=group_by + ['metric:process_name'],
                     metric_filter={'metric:process_name': process_name_re}))
                | expr.Join(
                    left_name='start', left_default=0, right_name='end', right_default=0)
                | m.Point(
                    m.Cond(m.VAL['end'] != 0, m.VAL['end'], k.TimestampMicros() /
                           1000000L) - m.Cond(m.VAL['start'] != 0, m.VAL['start'],
                                              m.TimestampMicros() / 1000000L)))
      """)  # noqa
      expected_formatted_code = textwrap.dedent("""\
          def _():
            return (
                (Gauge(
                    metric='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
                    group_by=group_by + ['metric:process_name'],
                    metric_filter={'metric:process_name': process_name_re}),
                 Gauge(
                     metric='bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
                     group_by=group_by + ['metric:process_name'],
                     metric_filter={'metric:process_name': process_name_re}))
                | expr.Join(
                    left_name='start', left_default=0, right_name='end', right_default=0)
                | m.Point(
                    m.Cond(m.VAL['end'] != 0, m.VAL['end'],
                           k.TimestampMicros() / 1000000L) -
                    m.Cond(m.VAL['start'] != 0, m.VAL['start'],
                           m.TimestampMicros() / 1000000L)))
      """)  # noqa
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB66011084(self):
      unformatted_code = textwrap.dedent("""\
          X = {
          "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":  # Comment 1.
          ([] if True else [ # Comment 2.
              "bbbbbbbbbbbbbbbbbbb",  # Comment 3.
              "cccccccccccccccccccccccc", # Comment 4.
              "ddddddddddddddddddddddddd", # Comment 5.
              "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", # Comment 6.
              "fffffffffffffffffffffffffffffff", # Comment 7.
              "ggggggggggggggggggggggggggg", # Comment 8.
              "hhhhhhhhhhhhhhhhhh",  # Comment 9.
          ]),
          }
      """)
      expected_formatted_code = textwrap.dedent("""\
          X = {
              "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":  # Comment 1.
                  ([] if True else [  # Comment 2.
                      "bbbbbbbbbbbbbbbbbbb",  # Comment 3.
                      "cccccccccccccccccccccccc",  # Comment 4.
                      "ddddddddddddddddddddddddd",  # Comment 5.
                      "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",  # Comment 6.
                      "fffffffffffffffffffffffffffffff",  # Comment 7.
                      "ggggggggggggggggggggggggggg",  # Comment 8.
                      "hhhhhhhhhhhhhhhhhh",  # Comment 9.
                  ]),
          }
      """)
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB67455376(self):
      unformatted_code = textwrap.dedent("""\
          sponge_ids.extend(invocation.id() for invocation in self._client.GetInvocationsByLabels(labels))
      """)  # noqa
      expected_formatted_code = textwrap.dedent("""\
          sponge_ids.extend(invocation.id()
                            for invocation in self._client.GetInvocationsByLabels(labels))
      """)  # noqa
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB35210351(self):
      unformatted_code = textwrap.dedent("""\
          def _():
            config.AnotherRuleThing(
                'the_title_to_the_thing_here',
                {'monitorname': 'firefly',
                 'service': ACCOUNTING_THING,
                 'severity': 'the_bug',
                 'monarch_module_name': alerts.TheLabel(qa_module_regexp, invert=True)},
                fanout,
                alerts.AlertUsToSomething(
                    GetTheAlertToIt('the_title_to_the_thing_here'),
                    GetNotificationTemplate('your_email_here')))
      """)  # noqa
      expected_formatted_code = textwrap.dedent("""\
          def _():
            config.AnotherRuleThing(
                'the_title_to_the_thing_here', {
                    'monitorname': 'firefly',
                    'service': ACCOUNTING_THING,
                    'severity': 'the_bug',
                    'monarch_module_name': alerts.TheLabel(qa_module_regexp, invert=True)
                }, fanout,
                alerts.AlertUsToSomething(
                    GetTheAlertToIt('the_title_to_the_thing_here'),
                    GetNotificationTemplate('your_email_here')))
      """)  # noqa
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB34774905(self):
      unformatted_code = textwrap.dedent("""\
          x=[VarExprType(ir_name=IrName( value='x',
          expr_type=UnresolvedAttrExprType( atom=UnknownExprType(), attr_name=IrName(
              value='x', expr_type=UnknownExprType(), usage='UNKNOWN', fqn=None,
              astn=None), usage='REF'), usage='ATTR', fqn='<attr>.x', astn=None))]
      """)  # noqa
      expected_formatted_code = textwrap.dedent("""\
          x = [
              VarExprType(
                  ir_name=IrName(
                      value='x',
                      expr_type=UnresolvedAttrExprType(
                          atom=UnknownExprType(),
                          attr_name=IrName(
                              value='x',
                              expr_type=UnknownExprType(),
                              usage='UNKNOWN',
                              fqn=None,
                              astn=None),
                          usage='REF'),
                      usage='ATTR',
                      fqn='<attr>.x',
                      astn=None))
          ]
      """)
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB65176185(self):
      code = textwrap.dedent("""\
          xx = zip(*[(a, b) for (a, b, c) in yy])
      """)
      llines = yapf_test_helper.ParseAndUnwrap(code)
      self.assertCodeEqual(code, reformatter.Reformat(llines))
  
    def testB35210166(self):
      unformatted_code = textwrap.dedent("""\
          def _():
            query = (
                m.Fetch(n.Raw('monarch.BorgTask', '/proc/container/memory/usage'), { 'borg_user': borguser, 'borg_job': jobname })
                | o.Window(m.Align('5m')) | p.GroupBy(['borg_user', 'borg_job', 'borg_cell'], q.Mean()))
      """)  # noqa
      expected_formatted_code = textwrap.dedent("""\
          def _():
            query = (
                m.Fetch(
                    n.Raw('monarch.BorgTask', '/proc/container/memory/usage'), {
                        'borg_user': borguser,
                        'borg_job': jobname
                    })
                | o.Window(m.Align('5m'))
                | p.GroupBy(['borg_user', 'borg_job', 'borg_cell'], q.Mean()))
      """)
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
      self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(llines))
  
    def testB32167774(self):
      unformatted_code = textwrap.dedent("""\
          X = (
              'is_official',
              'is_cover',
              'is_remix',
              'is_instrumental',
              'is_live',
              'has_lyrics',
              'is_album',
              'is_compilation',)
      """)
      expected_formatted_code = textwrap.dedent("""\
          X = (
              'is_official',
              'is_cover',
              'is_remix',
              'is_instrumental',
              'is_live',
              'has_lyrics',
              'is_album',
              'is_compilation',
          )
      """)
      llines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
  