aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2020-07-15 07:30:55 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-07-15 07:30:55 +0000
commit4ca0b90aa5b7e4fbcb3c5992799e99fee5e872af (patch)
treecabee042cccc859da72b3bbae22fe19450728888
parent9326f1e03e13f714d4b08cc70d5256779a093fe1 (diff)
parent00ebc1ad7d9dc274cfabf21669cfa03cf7802710 (diff)
downloadrepohooks-4ca0b90aa5b7e4fbcb3c5992799e99fee5e872af.tar.gz
Merge "pylint: always run python3 check with --py3" am: 00ebc1ad7d
Original change: https://android-review.googlesource.com/c/platform/tools/repohooks/+/1363136 Change-Id: I6218a1ec51ce8fc28202b379faa51d573a955b98
-rwxr-xr-xtools/pylint.py24
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,