From b9e2fda431ec22ec1048e654a0ff7e4e387fbfd1 Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Tue, 25 Sep 2018 16:49:39 -0700 Subject: [PATCH 1/3] Add pytype to api_core's setup.cfg. With these changes, pytype can now be run on api_core with the following steps in a Python 3.5 or 3.6 virtualenv: $ git clone git@github.com:GoogleCloudPlatform/google-cloud-python.git $ pip install googleapis-common-protos protobuf google-auth requests \ setuptools six pytz futures grpcio grpcio-gcp $ pip install pytype $ cd google-cloud-python/api_core/ $ pytype -V3.5 # or 3.6 --- api_core/nox.py | 3 ++- api_core/setup.cfg | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/api_core/nox.py b/api_core/nox.py index dacfbb53e74d..40e548330acc 100644 --- a/api_core/nox.py +++ b/api_core/nox.py @@ -15,7 +15,8 @@ from __future__ import absolute_import import os -import nox +# https://github.com/google/importlab/issues/25 +import nox # pytype: disable=import-error @nox.session diff --git a/api_core/setup.cfg b/api_core/setup.cfg index 2a9acf13daa9..413c7d217d4e 100644 --- a/api_core/setup.cfg +++ b/api_core/setup.cfg @@ -1,2 +1,8 @@ [bdist_wheel] universal = 1 + +[pytype] +inputs = + . +exclude = + tests/ From 4d17f0786ddd860714e98252d37c9f1462f528e5 Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Tue, 25 Sep 2018 18:10:52 -0700 Subject: [PATCH 2/3] Add a pytype session to nox.py. --- api_core/nox.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/api_core/nox.py b/api_core/nox.py index 40e548330acc..6ca1170b5377 100644 --- a/api_core/nox.py +++ b/api_core/nox.py @@ -109,6 +109,20 @@ def lint_setup_py(session): 'python', 'setup.py', 'check', '--restructuredtext', '--strict') +# No 2.7 due to https://github.com/google/importlab/issues/26. +# No 3.7 because pytype supports up to 3.6 only. +@nox.session +@nox.parametrize('py', ['3.5', '3.6']) +def pytype(session, py): + """Run type-checking.""" + session.interpreter = 'python{}'.format(py) + session.install('.', + 'grpcio >= 1.8.2', + 'grpcio-gcp >= 0.2.2', + 'pytype >= 2018.9.26') + session.run('pytype', '-V{}'.format(py)) + + @nox.session def cover(session): """Run the final coverage report. From 6f51f03694b613f7912529bf5e1401dd77848fb5 Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Thu, 27 Sep 2018 10:06:32 -0700 Subject: [PATCH 3/3] Run pytype for python 3.6 only. --- api_core/nox.py | 7 +++---- api_core/setup.cfg | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api_core/nox.py b/api_core/nox.py index 6ca1170b5377..7d14ad9befb1 100644 --- a/api_core/nox.py +++ b/api_core/nox.py @@ -112,15 +112,14 @@ def lint_setup_py(session): # No 2.7 due to https://github.com/google/importlab/issues/26. # No 3.7 because pytype supports up to 3.6 only. @nox.session -@nox.parametrize('py', ['3.5', '3.6']) -def pytype(session, py): +def pytype(session): """Run type-checking.""" - session.interpreter = 'python{}'.format(py) + session.interpreter = 'python3.6' session.install('.', 'grpcio >= 1.8.2', 'grpcio-gcp >= 0.2.2', 'pytype >= 2018.9.26') - session.run('pytype', '-V{}'.format(py)) + session.run('pytype') @nox.session diff --git a/api_core/setup.cfg b/api_core/setup.cfg index 413c7d217d4e..046436b8c99f 100644 --- a/api_core/setup.cfg +++ b/api_core/setup.cfg @@ -2,6 +2,7 @@ universal = 1 [pytype] +python_version = 3.6 inputs = . exclude =