Commit 866be0f2 authored by Peter Wen's avatar Peter Wen Committed by LUCI CQ

Add an option to specify pylint version

This allows us to migrate PRESUBMIT.py files over to pylint-2.6 bit by
bit. It also allows us to support and upgrade pylint to newer versions
in the future.

Bug: 1221143
Fixed: 1221143
Change-Id: I9af96f5f06caf48e9923ad5fae75b98a0a7aeb49
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2994723
Commit-Queue: Peter Wen <wnwen@chromium.org>
Auto-Submit: Peter Wen <wnwen@chromium.org>
Reviewed-by: 's avatarDirk Pranke <dpranke@google.com>
parent 6b084326
......@@ -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.
......
@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" %*
......@@ -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':
......
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