diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 3ffd7d4b9..40e91efdf 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -909,16 +909,21 @@ def GetPylint(input_api, files_to_skip=None, disabled_warnings=None, extra_paths_list=None, - pylintrc=None): + pylintrc=None, + version='1.5'): """Run pylint on python files. The default files_to_check enforces looking only at *.py files. + + Currently only pylint version '1.5' and '2.6' are supported. """ files_to_check = tuple(files_to_check or (r'.*\.py$', )) files_to_skip = tuple(files_to_skip or input_api.DEFAULT_FILES_TO_SKIP) extra_paths_list = extra_paths_list or [] + assert version in ('1.5', '2.6'), 'Unsupported pylint version: ' + version + if input_api.is_committing: error_type = output_api.PresubmitError else: @@ -969,7 +974,7 @@ def GetPylint(input_api, # Windows needs help running python files so we explicitly specify # the interpreter to use. It also has limitations on the size of # the command-line, so we pass arguments via a pipe. - tool = input_api.os_path.join(_HERE, 'pylint') + tool = input_api.os_path.join(_HERE, 'pylint-' + version) kwargs = {'env': env} if input_api.platform == 'win32': # On Windows, scripts on the current directory take precedence over PATH. diff --git a/pylint-1.5.bat b/pylint-1.5.bat new file mode 100644 index 000000000..4153985ed --- /dev/null +++ b/pylint-1.5.bat @@ -0,0 +1,12 @@ +@echo off +:: Copyright 2021 The Chromium Authors. All rights reserved. +:: Use of this source code is governed by a BSD-style license that can be +:: found in the LICENSE file. +setlocal + +:: Ensure that "depot_tools" is somewhere in PATH so this tool can be used +:: standalone, but allow other PATH manipulations to take priority. +set PATH=%PATH%;%~dp0 + +:: Defer control. +vpython "%~dp0\pylint-1.5" %* diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index 0ae7d80f5..402f1c295 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -2519,7 +2519,7 @@ the current line as well! subprocess.Popen.return_value = process presubmit.sigint_handler.wait.return_value = ('', None) - pylint = os.path.join(_ROOT, 'pylint') + pylint = os.path.join(_ROOT, 'pylint-1.5') pylintrc = os.path.join(_ROOT, 'pylintrc') env = {str('PYTHONPATH'): str('')} if sys.platform == 'win32':