diff options
author | Mike Frysinger <vapier@google.com> | 2020-07-15 07:10:24 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-07-15 07:10:24 +0000 |
commit | 00ebc1ad7d9dc274cfabf21669cfa03cf7802710 (patch) | |
tree | cabee042cccc859da72b3bbae22fe19450728888 | |
parent | d7363ec0659ab50df745f305d098ada4ca0adb8a (diff) | |
parent | a835e6df358a88ceedcaf9ddcd27b4b8720f3931 (diff) | |
download | repohooks-00ebc1ad7d9dc274cfabf21669cfa03cf7802710.tar.gz |
Merge "pylint: always run python3 check with --py3"
-rwxr-xr-x | tools/pylint.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/tools/pylint.py b/tools/pylint.py index b805df6..8af1adc 100755 --- a/tools/pylint.py +++ b/tools/pylint.py @@ -34,6 +34,19 @@ DEFAULT_PYLINTRC_PATH = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'pylintrc') +def is_pylint3(pylint): + """See whether |pylint| supports Python 3.""" + # Make sure pylint is using Python 3. + result = subprocess.run([pylint, '--version'], stdout=subprocess.PIPE, + check=True) + if b'Python 3' not in result.stdout: + print('%s: unable to locate a Python 3 version of pylint; Python 3 ' + 'support cannot be guaranteed' % (__file__,), file=sys.stderr) + return False + + return True + + def find_pylint3(): """Figure out the name of the pylint tool for Python 3. @@ -49,13 +62,6 @@ def find_pylint3(): 'sudo apt-get install pylint' % (__file__,), file=sys.stderr) sys.exit(1) - # Make sure pylint is using Python 3. - result = subprocess.run(['pylint', '--version'], stdout=subprocess.PIPE, - check=True) - if b'Python 3' not in result.stdout: - print('%s: unable to locate a Python 3 version of pylint; Python 3 ' - 'support cannot be guaranteed' % (__file__,), file=sys.stderr) - return 'pylint' @@ -87,6 +93,10 @@ def main(argv): else: pylint = 'pylint' + # Make sure pylint is using Python 3. + if opts.py3: + is_pylint3(pylint) + cmd = [pylint] if not opts.no_rcfile: # We assume pylint is running in the top directory of the project, |