Use pylint 2.7 for depot_tools

This includes a few fixes for specific errors, and disables several new
warnings introduced in this version, in order to allow for an incremental migration.

Bug:1262286
Change-Id: I4b8f8fc521386419a3121bbb07edc8ac83170a94
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3413679
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
diff --git a/git_cl.py b/git_cl.py
index 22c1585..74f04d9 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -638,7 +638,7 @@
     yapf_file = os.path.join(fpath, YAPF_CONFIG_FILENAME)
     if os.path.isfile(yapf_file):
       ret = yapf_file
-    elif fpath == top_dir or parent_dir == fpath:
+    elif fpath in (top_dir, parent_dir):
       # If we're at the top level directory, or if we're at root
       # there is no provided style.
       ret = None
@@ -1720,18 +1720,18 @@
       if not force:
         confirm_or_exit('If you know what you are doing', action='continue')
       return
-    else:
-      missing = (
-          ([] if gerrit_auth else [self._gerrit_host]) +
-          ([] if git_auth else [git_host]))
-      DieWithError('Credentials for the following hosts are required:\n'
-                   '  %s\n'
-                   'These are read from %s (or legacy %s)\n'
-                   '%s' % (
-                     '\n  '.join(missing),
-                     cookie_auth.get_gitcookies_path(),
-                     cookie_auth.get_netrc_path(),
-                     cookie_auth.get_new_password_message(git_host)))
+
+    missing = (
+        ([] if gerrit_auth else [self._gerrit_host]) +
+        ([] if git_auth else [git_host]))
+    DieWithError('Credentials for the following hosts are required:\n'
+                 '  %s\n'
+                 'These are read from %s (or legacy %s)\n'
+                 '%s' % (
+                   '\n  '.join(missing),
+                   cookie_auth.get_gitcookies_path(),
+                   cookie_auth.get_netrc_path(),
+                   cookie_auth.get_new_password_message(git_host)))
 
   def EnsureCanUploadPatchset(self, force):
     if not self.GetIssue():
@@ -1820,9 +1820,9 @@
       if m.get('author', {}).get('_account_id') == owner:
         # Most recent message was by owner.
         return 'waiting'
-      else:
-        # Some reply from non-owner.
-        return 'reply'
+
+      # Some reply from non-owner.
+      return 'reply'
 
     # Somehow there are no messages even though there are reviewers.
     return 'unsent'
@@ -1845,9 +1845,9 @@
 
     data = self._GetChangeDetail(['ALL_REVISIONS'])
     patchset = data['revisions'][data['current_revision']]['_number']
-    dry_run = set([int(m['_revision_number'])
-        for m in data.get('messages', [])
-        if m.get('tag', '').endswith('dry-run')])
+    dry_run = {int(m['_revision_number'])
+               for m in data.get('messages', [])
+               if m.get('tag', '').endswith('dry-run')}
 
     for revision_info in sorted(data.get('revisions', {}).values(),
         key=lambda c: c['_number'], reverse=True):
@@ -2634,8 +2634,8 @@
     if git_footers.get_footer_change_id(new_log_desc):
       print('git-cl: Added Change-Id to commit message.')
       return new_log_desc
-    else:
-      DieWithError('ERROR: Gerrit commit-msg hook not installed.')
+
+    DieWithError('ERROR: Gerrit commit-msg hook not installed.')
 
   def CannotTriggerTryJobReason(self):
     try:
@@ -3341,10 +3341,10 @@
     print('Current base-url:')
     return RunGit(['config', 'branch.%s.base-url' % branch],
                   error_ok=False).strip()
-  else:
-    print('Setting base-url to %s' % args[0])
-    return RunGit(['config', 'branch.%s.base-url' % branch, args[0]],
-                  error_ok=False).strip()
+
+  print('Setting base-url to %s' % args[0])
+  return RunGit(['config', 'branch.%s.base-url' % branch, args[0]],
+                error_ok=False).strip()
 
 
 def color_for_status(status):
@@ -3605,13 +3605,15 @@
   if options.dry_run:
     print('\nNo changes were made (dry run).\n')
     return 0
-  elif any(branch == current_branch for branch, _ in proposal):
+
+  if any(branch == current_branch for branch, _ in proposal):
     print('You are currently on a branch \'%s\' which is associated with a '
           'closed codereview issue, so archive cannot proceed. Please '
           'checkout another branch and run this command again.' %
           current_branch)
     return 1
-  elif not options.force:
+
+  if not options.force:
     answer = gclient_utils.AskForData('\nProceed with deletion (Y/n)? ').lower()
     if answer not in ('y', ''):
       print('Aborted.')
@@ -4148,7 +4150,9 @@
       if not match:
         # This is a branch path but not one we recognize; use as-is.
         remote_branch = target_branch
+  # pylint: disable=consider-using-get
   elif remote_branch in REFS_THAT_ALIAS_TO_OTHER_REFS:
+    # pylint: enable=consider-using-get
     # Handle the refs that need to land in different refs.
     remote_branch = REFS_THAT_ALIAS_TO_OTHER_REFS[remote_branch]
 
@@ -4565,8 +4569,10 @@
     status = str(urllib.request.urlopen(url).read().lower())
     if status.find('closed') != -1 or status == '0':
       return 'closed'
-    elif status.find('open') != -1 or status == '1':
+
+    if status.find('open') != -1 or status == '1':
       return 'open'
+
     return 'unknown'
   return 'unset'
 
@@ -5102,8 +5108,8 @@
 
   if opts.presubmit and rustfmt_exitcode != 0:
     return 2
-  else:
-    return 0
+
+  return 0
 
 
 def MatchingFileType(file_name, extensions):