llvm_tools: fix yapf warnings

This CL applies fixes automatically generated by yapf during presubmit
hook as well as a few manual fixes:
 * Removing erroneous `verbose` argument from call to RunTryJobs
 * Replacing / with parenthsis for long lines
 * Shortened some variable names to fix lines that were too long

BUG=None
TEST=rerean unit tests

Change-Id: Ic6ed4bb74f067dd5c67991481caf75d8829bf86e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3248930
Tested-by: Ryan Beltran <ryanbeltran@chromium.org>
Auto-Submit: Ryan Beltran <ryanbeltran@chromium.org>
Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
diff --git a/llvm_tools/llvm_bisection.py b/llvm_tools/llvm_bisection.py
index baaec70..0148efd 100755
--- a/llvm_tools/llvm_bisection.py
+++ b/llvm_tools/llvm_bisection.py
@@ -23,6 +23,7 @@
 import update_chromeos_llvm_hash
 import update_tryjob_status
 
+
 class BisectionExitStatus(enum.Enum):
   """Exit code when performing bisection."""
 
@@ -51,18 +52,16 @@
       'the first bad version (default: %(default)s)')
 
   # Add argument for the good LLVM revision for bisection.
-  parser.add_argument(
-      '--start_rev',
-      required=True,
-      type=int,
-      help='The good revision for the bisection.')
+  parser.add_argument('--start_rev',
+                      required=True,
+                      type=int,
+                      help='The good revision for the bisection.')
 
   # Add argument for the bad LLVM revision for bisection.
-  parser.add_argument(
-      '--end_rev',
-      required=True,
-      type=int,
-      help='The bad revision for the bisection.')
+  parser.add_argument('--end_rev',
+                      required=True,
+                      type=int,
+                      help='The bad revision for the bisection.')
 
   # Add argument for the absolute path to the file that contains information on
   # the previous tested svn version.
@@ -88,42 +87,38 @@
       'of updating the packages')
 
   # Add argument for custom options for the tryjob.
-  parser.add_argument(
-      '--options',
-      required=False,
-      nargs='+',
-      help='options to use for the tryjob testing')
+  parser.add_argument('--options',
+                      required=False,
+                      nargs='+',
+                      help='options to use for the tryjob testing')
 
   # Add argument for the builder to use for the tryjob.
-  parser.add_argument(
-      '--builder', required=True, help='builder to use for the tryjob testing')
+  parser.add_argument('--builder',
+                      required=True,
+                      help='builder to use for the tryjob testing')
 
   # Add argument for the description of the tryjob.
-  parser.add_argument(
-      '--description',
-      required=False,
-      nargs='+',
-      help='the description of the tryjob')
+  parser.add_argument('--description',
+                      required=False,
+                      nargs='+',
+                      help='the description of the tryjob')
 
   # Add argument for a specific chroot path.
-  parser.add_argument(
-      '--chroot_path',
-      default=cros_root,
-      help='the path to the chroot (default: %(default)s)')
+  parser.add_argument('--chroot_path',
+                      default=cros_root,
+                      help='the path to the chroot (default: %(default)s)')
 
   # Add argument for whether to display command contents to `stdout`.
-  parser.add_argument(
-      '--verbose',
-      action='store_true',
-      help='display contents of a command to the terminal '
-      '(default: %(default)s)')
+  parser.add_argument('--verbose',
+                      action='store_true',
+                      help='display contents of a command to the terminal '
+                      '(default: %(default)s)')
 
   # Add argument for whether to display command contents to `stdout`.
-  parser.add_argument(
-      '--nocleanup',
-      action='store_false',
-      dest='cleanup',
-      help='Abandon CLs created for bisectoin')
+  parser.add_argument('--nocleanup',
+                      action='store_false',
+                      dest='cleanup',
+                      help='Abandon CLs created for bisectoin')
 
   args_output = parser.parse_args()
 
@@ -174,8 +169,7 @@
 
   all_bad_revisions = [end]
   all_bad_revisions.extend(
-      cur_tryjob['rev']
-      for cur_tryjob in tryjobs
+      cur_tryjob['rev'] for cur_tryjob in tryjobs
       if cur_tryjob['status'] == update_tryjob_status.TryjobStatus.BAD.value)
 
   # The minimum value for the 'bad' field in the tryjobs is the new end
@@ -184,8 +178,7 @@
 
   all_good_revisions = [start]
   all_good_revisions.extend(
-      cur_tryjob['rev']
-      for cur_tryjob in tryjobs
+      cur_tryjob['rev'] for cur_tryjob in tryjobs
       if cur_tryjob['status'] == update_tryjob_status.TryjobStatus.GOOD.value)
 
   # The maximum value for the 'good' field in the tryjobs is the new start
@@ -205,8 +198,8 @@
   pending_revisions = {
       tryjob['rev']
       for tryjob in tryjobs
-      if tryjob['status'] == update_tryjob_status.TryjobStatus.PENDING.value and
-      good_rev < tryjob['rev'] < bad_rev
+      if tryjob['status'] == update_tryjob_status.TryjobStatus.PENDING.value
+      and good_rev < tryjob['rev'] < bad_rev
   }
 
   # Find all revisions that are to be skipped within 'good_rev' and 'bad_rev'.
@@ -217,8 +210,8 @@
   skip_revisions = {
       tryjob['rev']
       for tryjob in tryjobs
-      if tryjob['status'] == update_tryjob_status.TryjobStatus.SKIP.value and
-      good_rev < tryjob['rev'] < bad_rev
+      if tryjob['status'] == update_tryjob_status.TryjobStatus.SKIP.value
+      and good_rev < tryjob['rev'] < bad_rev
   }
 
   return good_rev, bad_rev, pending_revisions, skip_revisions
@@ -301,56 +294,56 @@
 
   bisect_state = LoadStatusFile(args_output.last_tested, start, end)
   if start != bisect_state['start'] or end != bisect_state['end']:
-    raise ValueError(f'The start {start} or the end {end} version provided is '
-                     f'different than "start" {bisect_state["start"]} or "end" '
-                     f'{bisect_state["end"]} in the .JSON file')
+    raise ValueError(
+        f'The start {start} or the end {end} version provided is '
+        f'different than "start" {bisect_state["start"]} or "end" '
+        f'{bisect_state["end"]} in the .JSON file')
 
-  # Pending and skipped revisions are between 'start_revision' and
-  # 'end_revision'.
-  start_revision, end_revision, pending_revisions, skip_revisions = \
-      GetRemainingRange(start, end, bisect_state['jobs'])
+  # Pending and skipped revisions are between 'start_rev' and 'end_rev'.
+  start_rev, end_rev, pending_revs, skip_revs = GetRemainingRange(
+      start, end, bisect_state['jobs'])
 
-  revisions, git_hashes = GetCommitsBetween(start_revision, end_revision,
+  revisions, git_hashes = GetCommitsBetween(start_rev, end_rev,
                                             args_output.parallel,
-                                            args_output.src_path,
-                                            pending_revisions, skip_revisions)
+                                            args_output.src_path, pending_revs,
+                                            skip_revs)
 
-  # No more revisions between 'start_revision' and 'end_revision', so
+  # No more revisions between 'start_rev' and 'end_rev', so
   # bisection is complete.
   #
-  # This is determined by finding all valid revisions between 'start_revision'
-  # and 'end_revision' and that are NOT in the 'pending' and 'skipped' set.
+  # This is determined by finding all valid revisions between 'start_rev'
+  # and 'end_rev' and that are NOT in the 'pending' and 'skipped' set.
   if not revisions:
-    if pending_revisions:
+    if pending_revs:
       # Some tryjobs are not finished which may change the actual bad
       # commit/revision when those tryjobs are finished.
-      no_revisions_message = (f'No revisions between start {start_revision} '
-                              f'and end {end_revision} to create tryjobs\n')
+      no_revisions_message = (f'No revisions between start {start_rev} '
+                              f'and end {end_rev} to create tryjobs\n')
 
-      if pending_revisions:
-        no_revisions_message += (
-            'The following tryjobs are pending:\n' +
-            '\n'.join(str(rev) for rev in pending_revisions) + '\n')
+      if pending_revs:
+        no_revisions_message += ('The following tryjobs are pending:\n' +
+                                 '\n'.join(str(rev)
+                                           for rev in pending_revs) + '\n')
 
-      if skip_revisions:
+      if skip_revs:
         no_revisions_message += ('The following tryjobs were skipped:\n' +
-                                 '\n'.join(str(rev) for rev in skip_revisions) +
-                                 '\n')
+                                 '\n'.join(str(rev)
+                                           for rev in skip_revs) + '\n')
 
       raise ValueError(no_revisions_message)
 
     print(f'Finished bisecting for {args_output.last_tested}')
     if args_output.src_path:
       bad_llvm_hash = get_llvm_hash.GetGitHashFrom(args_output.src_path,
-                                                   end_revision)
+                                                   end_rev)
     else:
-      bad_llvm_hash = get_llvm_hash.LLVMHash().GetLLVMHash(end_revision)
-    print(f'The bad revision is {end_revision} and its commit hash is '
+      bad_llvm_hash = get_llvm_hash.LLVMHash().GetLLVMHash(end_rev)
+    print(f'The bad revision is {end_rev} and its commit hash is '
           f'{bad_llvm_hash}')
-    if skip_revisions:
-      skip_revisions_message = ('\nThe following revisions were skipped:\n' +
-                                '\n'.join(str(rev) for rev in skip_revisions))
-      print(skip_revisions_message)
+    if skip_revs:
+      skip_revs_message = ('\nThe following revisions were skipped:\n' +
+                           '\n'.join(str(rev) for rev in skip_revs))
+      print(skip_revs_message)
 
     if args_output.cleanup:
       # Abandon all the CLs created for bisection
@@ -374,10 +367,9 @@
       raise ValueError(f'Revision {rev} exists already in "jobs"')
 
   Bisect(revisions, git_hashes, bisect_state, args_output.last_tested,
-         update_chromeos_llvm_hash.DEFAULT_PACKAGES,
-         args_output.chroot_path, patch_metadata_file,
-         args_output.extra_change_lists, args_output.options,
-         args_output.builder, args_output.verbose)
+         update_chromeos_llvm_hash.DEFAULT_PACKAGES, args_output.chroot_path,
+         patch_metadata_file, args_output.extra_change_lists,
+         args_output.options, args_output.builder, args_output.verbose)
 
 
 if __name__ == '__main__':
diff --git a/llvm_tools/modify_a_tryjob.py b/llvm_tools/modify_a_tryjob.py
index 1bca30d..519fb51 100755
--- a/llvm_tools/modify_a_tryjob.py
+++ b/llvm_tools/modify_a_tryjob.py
@@ -57,11 +57,10 @@
 
   # Add argument that determines which revision to search for in the list of
   # tryjobs.
-  parser.add_argument(
-      '--revision',
-      required=True,
-      type=int,
-      help='The revision to either remove or relaunch.')
+  parser.add_argument('--revision',
+                      required=True,
+                      type=int,
+                      help='The revision to either remove or relaunch.')
 
   # Add argument for other change lists that want to run alongside the tryjob.
   parser.add_argument(
@@ -72,40 +71,38 @@
       'of updating the packages')
 
   # Add argument for custom options for the tryjob.
-  parser.add_argument(
-      '--options',
-      required=False,
-      nargs='+',
-      help='options to use for the tryjob testing')
+  parser.add_argument('--options',
+                      required=False,
+                      nargs='+',
+                      help='options to use for the tryjob testing')
 
   # Add argument for the builder to use for the tryjob.
-  parser.add_argument('--builder', help='builder to use for the tryjob testing')
+  parser.add_argument('--builder',
+                      help='builder to use for the tryjob testing')
 
   # Add argument for a specific chroot path.
-  parser.add_argument(
-      '--chroot_path',
-      default=cros_root,
-      help='the path to the chroot (default: %(default)s)')
+  parser.add_argument('--chroot_path',
+                      default=cros_root,
+                      help='the path to the chroot (default: %(default)s)')
 
   # Add argument for whether to display command contents to `stdout`.
-  parser.add_argument(
-      '--verbose',
-      action='store_true',
-      help='display contents of a command to the terminal '
-      '(default: %(default)s)')
+  parser.add_argument('--verbose',
+                      action='store_true',
+                      help='display contents of a command to the terminal '
+                      '(default: %(default)s)')
 
   args_output = parser.parse_args()
 
-  if not os.path.isfile(args_output.status_file) or \
-      not args_output.status_file.endswith('.json'):
+  if (not os.path.isfile(args_output.status_file)
+      or not args_output.status_file.endswith('.json')):
     raise ValueError('File does not exist or does not ending in ".json" '
                      ': %s' % args_output.status_file)
 
-  if args_output.modify_tryjob == ModifyTryjob.ADD.value and \
-      not args_output.builder:
+  if (args_output.modify_tryjob == ModifyTryjob.ADD.value
+      and not args_output.builder):
     raise ValueError('A builder is required for adding a tryjob.')
-  elif args_output.modify_tryjob != ModifyTryjob.ADD.value and \
-      args_output.builder:
+  elif (args_output.modify_tryjob != ModifyTryjob.ADD.value
+        and args_output.builder):
     raise ValueError('Specifying a builder is only available when adding a '
                      'tryjob.')
 
@@ -234,13 +231,13 @@
         bisect_contents['jobs'][tryjob_index]['cl'],
         bisect_contents['jobs'][tryjob_index]['extra_cls'],
         bisect_contents['jobs'][tryjob_index]['options'],
-        bisect_contents['jobs'][tryjob_index]['builder'], chroot_path, verbose)
+        bisect_contents['jobs'][tryjob_index]['builder'], chroot_path)
 
     bisect_contents['jobs'][tryjob_index][
         'status'] = update_tryjob_status.TryjobStatus.PENDING.value
     bisect_contents['jobs'][tryjob_index]['link'] = tryjob_results[0]['link']
-    bisect_contents['jobs'][tryjob_index]['buildbucket_id'] = tryjob_results[0][
-        'buildbucket_id']
+    bisect_contents['jobs'][tryjob_index]['buildbucket_id'] = tryjob_results[
+        0]['buildbucket_id']
 
     print('Successfully relaunched the tryjob for revision %d and updated '
           'the tryjob link to %s' % (revision, tryjob_results[0]['link']))
@@ -274,7 +271,10 @@
                      modify_tryjob)
 
   with open(status_file, 'w') as update_tryjobs:
-    json.dump(bisect_contents, update_tryjobs, indent=4, separators=(',', ': '))
+    json.dump(bisect_contents,
+              update_tryjobs,
+              indent=4,
+              separators=(',', ': '))
 
 
 def main():
@@ -287,9 +287,9 @@
   PerformTryjobModification(args_output.revision,
                             ModifyTryjob(args_output.modify_tryjob),
                             args_output.status_file,
-                            args_output.extra_change_lists, args_output.options,
-                            args_output.builder, args_output.chroot_path,
-                            args_output.verbose)
+                            args_output.extra_change_lists,
+                            args_output.options, args_output.builder,
+                            args_output.chroot_path, args_output.verbose)
 
 
 if __name__ == '__main__':
diff --git a/llvm_tools/update_chromeos_llvm_hash.py b/llvm_tools/update_chromeos_llvm_hash.py
index 9365f00..4e9b910 100755
--- a/llvm_tools/update_chromeos_llvm_hash.py
+++ b/llvm_tools/update_chromeos_llvm_hash.py
@@ -34,6 +34,7 @@
     'sys-libs/llvm-libunwind',
 ]
 
+
 # Specify which LLVM hash to update
 class LLVMVariant(enum.Enum):
   """Represent the LLVM hash in an ebuild file to update."""
@@ -77,26 +78,23 @@
       description="Updates the build's hash for llvm-next.")
 
   # Add argument for a specific chroot path.
-  parser.add_argument(
-      '--chroot_path',
-      default=defaultCrosRoot(),
-      help='the path to the chroot (default: %(default)s)')
+  parser.add_argument('--chroot_path',
+                      default=defaultCrosRoot(),
+                      help='the path to the chroot (default: %(default)s)')
 
   # Add argument for specific builds to uprev and update their llvm-next hash.
-  parser.add_argument(
-      '--update_packages',
-      default=DEFAULT_PACKAGES,
-      required=False,
-      nargs='+',
-      help='the ebuilds to update their hash for llvm-next '
-      '(default: %(default)s)')
+  parser.add_argument('--update_packages',
+                      default=DEFAULT_PACKAGES,
+                      required=False,
+                      nargs='+',
+                      help='the ebuilds to update their hash for llvm-next '
+                      '(default: %(default)s)')
 
   # Add argument for whether to display command contents to `stdout`.
-  parser.add_argument(
-      '--verbose',
-      action='store_true',
-      help='display contents of a command to the terminal '
-      '(default: %(default)s)')
+  parser.add_argument('--verbose',
+                      action='store_true',
+                      help='display contents of a command to the terminal '
+                      '(default: %(default)s)')
 
   # Add argument for the LLVM hash to update
   parser.add_argument(
@@ -322,9 +320,11 @@
         count=1)
   # any other package
   else:
-    new_ebuild, is_changed = re.subn(
-        r'(\d+)\.(\d+)_pre([0-9]+)',
-        '%s.\\2_pre%s' % (llvm_major_version, svn_version), ebuild, count=1)
+    new_ebuild, is_changed = re.subn(r'(\d+)\.(\d+)_pre([0-9]+)',
+                                     '%s.\\2_pre%s' %
+                                     (llvm_major_version, svn_version),
+                                     ebuild,
+                                     count=1)
 
   if not is_changed:  # failed to increment the revision number
     raise ValueError('Failed to uprev the ebuild.')
@@ -405,7 +405,8 @@
   # Cmd to stage the patch metadata file for commit.
   subprocess.check_output([
       'git', '-C',
-      os.path.dirname(patch_metadata_file_path), 'add', patch_metadata_file_path
+      os.path.dirname(patch_metadata_file_path), 'add',
+      patch_metadata_file_path
   ])
 
 
@@ -427,9 +428,9 @@
   # changed, if so, add which patches have changed to the commit
   # message.
   for package_name, patch_info_dict in package_info_dict.items():
-    if (patch_info_dict['disabled_patches'] or
-        patch_info_dict['removed_patches'] or
-        patch_info_dict['modified_metadata']):
+    if (patch_info_dict['disabled_patches']
+        or patch_info_dict['removed_patches']
+        or patch_info_dict['modified_metadata']):
       cur_package_header = '\nFor the package %s:' % package_name
       commit_messages.append(cur_package_header)
 
@@ -608,16 +609,16 @@
   git_hash, svn_version = get_llvm_hash.GetLLVMHashAndVersionFromSVNOption(
       git_hash_source)
 
-  change_list = UpdatePackages(
-      args_output.update_packages,
-      llvm_variant,
-      git_hash,
-      svn_version,
-      args_output.chroot_path,
-      args_output.patch_metadata_file,
-      failure_modes.FailureModes(args_output.failure_mode),
-      git_hash_source,
-      extra_commit_msg=None)
+  change_list = UpdatePackages(args_output.update_packages,
+                               llvm_variant,
+                               git_hash,
+                               svn_version,
+                               args_output.chroot_path,
+                               args_output.patch_metadata_file,
+                               failure_modes.FailureModes(
+                                   args_output.failure_mode),
+                               git_hash_source,
+                               extra_commit_msg=None)
 
   print('Successfully updated packages to %s (%d)' % (git_hash, svn_version))
   print('Gerrit URL: %s' % change_list.url)
diff --git a/llvm_tools/update_packages_and_run_tests.py b/llvm_tools/update_packages_and_run_tests.py
index 92f4930..2e4a905 100755
--- a/llvm_tools/update_packages_and_run_tests.py
+++ b/llvm_tools/update_packages_and_run_tests.py
@@ -21,6 +21,7 @@
 
 VALID_CQ_TRYBOTS = ['llvm', 'llvm-next', 'llvm-tot']
 
+
 def GetCommandLineArgs():
   """Parses the command line for the command line arguments.
 
@@ -50,10 +51,9 @@
       'of updating the packages')
 
   # Add argument for a specific chroot path.
-  parser.add_argument(
-      '--chroot_path',
-      default=cros_root,
-      help='the path to the chroot (default: %(default)s)')
+  parser.add_argument('--chroot_path',
+                      default=cros_root,
+                      help='the path to the chroot (default: %(default)s)')
 
   # Add argument to choose between llvm and llvm-next.
   parser.add_argument(
@@ -70,65 +70,58 @@
       'arguments.')
 
   # Add argument for the LLVM version to use.
-  parser.add_argument(
-      '--llvm_version',
-      type=get_llvm_hash.IsSvnOption,
-      required=True,
-      help='which git hash of LLVM to find '
-      '{google3, ToT, <svn_version>} '
-      '(default: finds the git hash of the google3 LLVM '
-      'version)')
+  parser.add_argument('--llvm_version',
+                      type=get_llvm_hash.IsSvnOption,
+                      required=True,
+                      help='which git hash of LLVM to find '
+                      '{google3, ToT, <svn_version>} '
+                      '(default: finds the git hash of the google3 LLVM '
+                      'version)')
 
   # Add argument to add reviewers for the created CL.
-  parser.add_argument(
-      '--reviewers',
-      nargs='+',
-      default=[],
-      help='The reviewers for the package update changelist')
+  parser.add_argument('--reviewers',
+                      nargs='+',
+                      default=[],
+                      help='The reviewers for the package update changelist')
 
   # Add argument for whether to display command contents to `stdout`.
-  parser.add_argument(
-      '--verbose',
-      action='store_true',
-      help='display contents of a command to the terminal '
-      '(default: %(default)s)')
+  parser.add_argument('--verbose',
+                      action='store_true',
+                      help='display contents of a command to the terminal '
+                      '(default: %(default)s)')
 
   subparsers = parser.add_subparsers(dest='subparser_name')
   subparser_names = []
   # Testing with the tryjobs.
   tryjob_subparser = subparsers.add_parser('tryjobs')
   subparser_names.append('tryjobs')
-  tryjob_subparser.add_argument(
-      '--builders',
-      required=True,
-      nargs='+',
-      default=[],
-      help='builders to use for the tryjob testing')
+  tryjob_subparser.add_argument('--builders',
+                                required=True,
+                                nargs='+',
+                                default=[],
+                                help='builders to use for the tryjob testing')
 
   # Add argument for custom options for the tryjob.
-  tryjob_subparser.add_argument(
-      '--options',
-      required=False,
-      nargs='+',
-      default=[],
-      help='options to use for the tryjob testing')
+  tryjob_subparser.add_argument('--options',
+                                required=False,
+                                nargs='+',
+                                default=[],
+                                help='options to use for the tryjob testing')
 
   # Testing with the recipe builders
   recipe_subparser = subparsers.add_parser('recipe')
   subparser_names.append('recipe')
-  recipe_subparser.add_argument(
-      '--options',
-      required=False,
-      nargs='+',
-      default=[],
-      help='options passed to the recipe builders')
+  recipe_subparser.add_argument('--options',
+                                required=False,
+                                nargs='+',
+                                default=[],
+                                help='options passed to the recipe builders')
 
-  recipe_subparser.add_argument(
-      '--builders',
-      required=True,
-      nargs='+',
-      default=[],
-      help='recipe builders to launch')
+  recipe_subparser.add_argument('--builders',
+                                required=True,
+                                nargs='+',
+                                default=[],
+                                help='recipe builders to launch')
 
   # Testing with CQ.
   cq_subparser = subparsers.add_parser('cq')
@@ -359,7 +352,8 @@
     return None
 
   # Cq-Depend must start a new paragraph prefixed with "Cq-Depend".
-  return '\nCq-Depend: ' + ', '.join(('chromium:%s' % i) for i in dependent_cls)
+  return '\nCq-Depend: ' + ', '.join(
+      ('chromium:%s' % i) for i in dependent_cls)
 
 
 def GetCQIncludeTrybotsString(trybot):