Make git_cl (and everything else not skipped under depot_tools)

pass pylint cleanly.

There should be no functional changes in this patch, although there's at least one minor bug that lint caught.

Review URL: http://codereview.chromium.org/6685023

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@78638 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
dpranke@chromium.org 15 years ago
parent 8d84041516
commit 97ae58eb0a

@ -38,14 +38,13 @@ def CommonChecks(input_api, output_api):
input_api, input_api,
output_api, output_api,
UNIT_TESTS)) UNIT_TESTS))
output.extend(WasGitClUploadHookModified(input_api, output_api))
white_list = [r'.*\.py$', r'^git-try$'] white_list = [r'.*\.py$', r'^git-try$']
black_list = list(input_api.DEFAULT_BLACK_LIST) + [ black_list = list(input_api.DEFAULT_BLACK_LIST) + [
r'^cpplint\.py$', r'^cpplint\.py$',
r'^git_cl[\/\\].*', r'^git_cl[\/\\]test[\/\\](local_)?rietveld.*',
r'^git_cl_repo[\/\\].*', r'^git_cl[\/\\]upload.*',
r'^git_cl[\/\\]test[\/\\]rietveld.*'] ]
output.extend(input_api.canned_checks.RunPylint( output.extend(input_api.canned_checks.RunPylint(
input_api, input_api,
output_api, output_api,
@ -65,13 +64,3 @@ def CheckChangeOnCommit(input_api, output_api):
input_api, input_api,
output_api)) output_api))
return output return output
def WasGitClUploadHookModified(input_api, output_api):
for affected_file in input_api.AffectedSourceFiles(None):
if (input_api.os_path.basename(affected_file.LocalPath()) ==
'git-cl-upload-hook'):
return [output_api.PresubmitPromptWarning(
'Don\'t forget to fix git-cl to download the newest version of '
'git-cl-upload-hook')]
return []

@ -660,7 +660,7 @@ class ExecutionQueue(object):
self.running.append(t) self.running.append(t)
else: else:
t.join() t.join()
sys.stdout.full_flush() sys.stdout.full_flush() # pylint: disable=E1101
if self.progress: if self.progress:
self.progress.update(1, t.item.name) self.progress.update(1, t.item.name)
assert not t.item.name in self.ran assert not t.item.name in self.ran

@ -28,7 +28,7 @@ def RunTests(input_api, output_api):
old_sys_path = sys.path old_sys_path = sys.path
try: try:
sys.path = [input_api.PresubmitLocalPath()] + sys.path sys.path = [input_api.PresubmitLocalPath()] + sys.path
from test import local_rietveld from test import local_rietveld # pylint: disable=W0403
server = local_rietveld.LocalRietveld() server = local_rietveld.LocalRietveld()
finally: finally:
sys.path = old_sys_path sys.path = old_sys_path

@ -7,20 +7,20 @@ import logging
import optparse import optparse
import os import os
import re import re
import StringIO
import subprocess import subprocess
import sys import sys
import tempfile import tempfile
import textwrap import textwrap
import upload
import urlparse import urlparse
import urllib2 import urllib2
try: try:
import readline import readline # pylint: disable=W0611
except ImportError: except ImportError:
pass pass
# TODO(dpranke): don't use relative import.
import upload # pylint: disable=W0403
try: try:
# TODO(dpranke): We wrap this in a try block for a limited form of # TODO(dpranke): We wrap this in a try block for a limited form of
# backwards-compatibility with older versions of git-cl that weren't # backwards-compatibility with older versions of git-cl that weren't
@ -29,7 +29,7 @@ try:
# once this has baked for a while and things seem safe. # once this has baked for a while and things seem safe.
depot_tools_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) depot_tools_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(depot_tools_path) sys.path.append(depot_tools_path)
import breakpad import breakpad # pylint: disable=W0611
except ImportError: except ImportError:
pass pass
@ -584,7 +584,7 @@ def LoadCodereviewSettingsFromFile(fileobj):
def CMDconfig(parser, args): def CMDconfig(parser, args):
"""edit configuration for this tree""" """edit configuration for this tree"""
(options, args) = parser.parse_args(args) _, args = parser.parse_args(args)
if len(args) == 0: if len(args) == 0:
GetCodereviewSettingsInteractively() GetCodereviewSettingsInteractively()
return 0 return 0
@ -650,7 +650,7 @@ def CMDissue(parser, args):
Pass issue number 0 to clear the current issue. Pass issue number 0 to clear the current issue.
""" """
(options, args) = parser.parse_args(args) _, args = parser.parse_args(args)
cl = Changelist() cl = Changelist()
if len(args) > 0: if len(args) > 0:
@ -1170,11 +1170,11 @@ def CMDpatch(parser, args):
if len(args) != 1: if len(args) != 1:
parser.print_help() parser.print_help()
return 1 return 1
input = args[0] issue_arg = args[0]
if re.match(r'\d+', input): if re.match(r'\d+', input):
# Input is an issue id. Figure out the URL. # Input is an issue id. Figure out the URL.
issue = input issue = issue_arg
server = settings.GetDefaultServerUrl() server = settings.GetDefaultServerUrl()
fetch = urllib2.urlopen('%s/%s' % (server, issue)).read() fetch = urllib2.urlopen('%s/%s' % (server, issue)).read()
m = re.search(r'/download/issue[0-9]+_[0-9]+.diff', fetch) m = re.search(r'/download/issue[0-9]+_[0-9]+.diff', fetch)
@ -1184,8 +1184,8 @@ def CMDpatch(parser, args):
url = '%s%s' % (server, m.group(0).strip()) url = '%s%s' % (server, m.group(0).strip())
else: else:
# Assume it's a URL to the patch. Default to http. # Assume it's a URL to the patch. Default to http.
input = FixUrl(input) issue_url = FixUrl(issue_arg)
match = re.match(r'.*?/issue(\d+)_\d+.diff', input) match = re.match(r'.*?/issue(\d+)_\d+.diff', issue_url)
if match: if match:
issue = match.group(1) issue = match.group(1)
url = input url = input
@ -1270,14 +1270,11 @@ def GetTreeStatusReason():
# on python 2.5 and it is only used for git-cl tree which isn't often used, # on python 2.5 and it is only used for git-cl tree which isn't often used,
# forcing everyone to install simplejson isn't efficient. # forcing everyone to install simplejson isn't efficient.
try: try:
import simplejson as json import simplejson as json # pylint: disable=F0401
except ImportError: except ImportError:
try: try:
import json import json
# Some versions of python2.5 have an incomplete json module. Check to make except ImportError:
# sure loads exists.
json.loads
except (ImportError, AttributeError):
print >> sys.stderr, 'Please install simplejson' print >> sys.stderr, 'Please install simplejson'
sys.exit(1) sys.exit(1)
@ -1291,7 +1288,7 @@ def GetTreeStatusReason():
def CMDtree(parser, args): def CMDtree(parser, args):
"""show the status of the tree""" """show the status of the tree"""
(options, args) = parser.parse_args(args) _, args = parser.parse_args(args)
status = GetTreeStatus() status = GetTreeStatus()
if 'unset' == status: if 'unset' == status:
print 'You must configure your tree status URL by running "git cl config".' print 'You must configure your tree status URL by running "git cl config".'
@ -1307,7 +1304,7 @@ def CMDtree(parser, args):
def CMDupstream(parser, args): def CMDupstream(parser, args):
"""print the name of the upstream branch, if any""" """print the name of the upstream branch, if any"""
(options, args) = parser.parse_args(args) _, args = parser.parse_args(args)
cl = Changelist() cl = Changelist()
print cl.GetUpstreamBranch() print cl.GetUpstreamBranch()
return 0 return 0
@ -1319,7 +1316,7 @@ def Command(name):
def CMDhelp(parser, args): def CMDhelp(parser, args):
"""print list of commands or help for a specific command""" """print list of commands or help for a specific command"""
(options, args) = parser.parse_args(args) _, args = parser.parse_args(args)
if len(args) == 1: if len(args) == 1:
return main(args + ['--help']) return main(args + ['--help'])
parser.print_help() parser.print_help()

Loading…
Cancel
Save