mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
This allows people to pin a specific version of pylint when running it. The default behavior is unchanged: we run pylint-1.5.6 still as we've created a vpython wheel in cipd for it. But for projects that want to move to a newer version, they can pick any of the new 1.x wrappers. Having the full set of versions here allows projects to incrementally move to newer versions as the lint delta between 1.5 & 1.6 tends to be much smaller than 1.5 & 1.9. We don't include support for the newer 2.x series as those only support Python 3 which the codebase isn't ready for. Bug: 866772 Test: `./pylint ...` still works & shows pylint-1.5 Test: `./pylint-1.5 ...` runs the v1.5 version Test: `./pylint-1.8 ...` runs the v1.8 version Change-Id: I7c47187493564db81e3eb28c6dbd09e6309ead46 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1752507 Reviewed-by: Robbie Iannucci <iannucci@chromium.org> Commit-Queue: Mike Frysinger <vapier@chromium.org>
46 lines
1.2 KiB
Python
Executable File
46 lines
1.2 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# Copyright 2019 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.
|
|
|
|
"""Chromium wrapper for pylint for passing args via stdin.
|
|
|
|
This will be executed by vpython with the right pylint versions.
|
|
"""
|
|
|
|
from __future__ import print_function
|
|
|
|
import os
|
|
import sys
|
|
|
|
from pylint import lint
|
|
|
|
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
PYLINT = os.path.join(HERE, 'pylint_main.py')
|
|
RC_FILE = os.path.join(HERE, 'pylintrc')
|
|
|
|
ARGS_ON_STDIN = '--args-on-stdin'
|
|
|
|
|
|
def main(argv):
|
|
"""Our main wrapper."""
|
|
# Add support for a custom mode where arguments are fed line by line on
|
|
# stdin. This allows us to get around command line length limitations.
|
|
if ARGS_ON_STDIN in argv:
|
|
argv = [x for x in argv if x != ARGS_ON_STDIN]
|
|
argv.extend(x.strip() for x in sys.stdin)
|
|
|
|
# We prepend the command-line with the depot_tools rcfile. If another rcfile
|
|
# is to be used, passing --rcfile a second time on the command-line will work
|
|
# fine.
|
|
if os.path.isfile(RC_FILE):
|
|
# The file can be removed to test 'normal' pylint behavior.
|
|
argv.insert(0, '--rcfile=%s' % RC_FILE)
|
|
|
|
lint.Run(argv)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main(sys.argv[1:]))
|