Commit ce71e67b authored by maruel@chromium.org's avatar maruel@chromium.org

Improve pylint error message with an old version is used.

Instead of crashing, prints an error message.

BUG=
TEST=


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@106867 0039d316-1c4b-4281-b951-d872f2087c98
parent 37ca0b1c
......@@ -634,6 +634,7 @@ def RunPylint(input_api, output_api, white_list=None, black_list=None):
# were listed, try to run pylint.
try:
from pylint import lint
from pylint.utils import UnknownMessage
input_api.logging.debug(
'Using pylint v%s from %s' % (lint.version, lint.__file__))
except ImportError:
......@@ -655,6 +656,8 @@ def RunPylint(input_api, output_api, white_list=None, black_list=None):
except SystemExit, e:
# pylint has the bad habit of calling sys.exit(), trap it here.
return e.code
except UnknownMessage, e:
return 'Please upgrade pylint: %s' % e
result = None
if not input_api.verbose:
......@@ -662,10 +665,10 @@ def RunPylint(input_api, output_api, white_list=None, black_list=None):
else:
for filename in sorted(files):
print('Running pylint on %s' % filename)
out = run_lint([filename])
if out:
result = out
if result:
result = run_lint([filename]) or result
if isinstance(result, basestring):
return [error_type(result)]
elif result:
return [error_type('Fix pylint errors first.')]
return []
finally:
......
......@@ -35,6 +35,7 @@ load-plugins=
# C0103: Invalid name ""
# C0111: Missing docstring
# C0302: Too many lines in module (N)
# I0010: Unable to consider inline option ''
# I0011: Locally disabling WNNNN
#
# It's a problem but not something we can fix right now.
......@@ -62,7 +63,7 @@ load-plugins=
# W0613: Unused argument ''
# W0703: Catch "Exception"
# W1201: Specify string format arguments as logging function parameters
disable=C0103,C0111,C0302,I0011,R0401,R0801,R0901,R0902,R0903,R0904,R0911,R0912,R0913,R0914,R0915,R0921,R0922,W0122,W0141,W0142,W0402,W0404,W0511,W0603,W0613,W0703,W1201
disable=C0103,C0111,C0302,I0010,I0011,R0401,R0801,R0901,R0902,R0903,R0904,R0911,R0912,R0913,R0914,R0915,R0921,R0922,W0122,W0141,W0142,W0402,W0404,W0511,W0603,W0613,W0703,W1201
[REPORTS]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment