aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-07-16 01:02:34 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-07-16 01:02:34 +0000
commit91fd2eed830b647f262dbc7df863ca8f390bf510 (patch)
treeb9c85413c1133725b7480aea80113a5ee15c0f54
parent4077b40951b599291304845509f1bd3944a803c9 (diff)
parent33e3a95389cdd3117bbd7ed6f99685f62b5c0e3b (diff)
downloadrepohooks-91fd2eed830b647f262dbc7df863ca8f390bf510.tar.gz
Snap for 6683823 from 33e3a95389cdd3117bbd7ed6f99685f62b5c0e3b to rvc-release
Change-Id: Iff9a3fcb0a2a1ef3e7023d159cb04e1f5444ff64
-rwxr-xr-xpre-upload.py2
-rwxr-xr-xtools/pylint.py24
2 files changed, 18 insertions, 8 deletions
diff --git a/pre-upload.py b/pre-upload.py
index d7c12aa..0d0afb6 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -38,7 +38,7 @@ elif sys.version_info.major == 3 and sys.version_info < (3, 4):
# We don't actually test <Python-3.6. Hope for the best!
print('repohooks: error: Python-3.4+ is required', file=sys.stderr)
sys.exit(1)
-elif sys.version_info.major == 3 and sys.version_info < (3, 6):
+elif sys.version_info < (3, 6):
# We want to get people off of old versions of Python.
print('repohooks: warning: Python-3.6+ is going to be required; '
'please upgrade soon to maintain support.', file=sys.stderr)
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,