Add type-checking via pytype to api_core. (#6116)
* 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 [email protected]: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
* Add a pytype session to nox.py.
* Run pytype for python 3.6 only.
diff --git a/nox.py b/nox.py
index dacfbb5..7d14ad9 100644
--- a/nox.py
+++ b/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
@@ -108,6 +109,19 @@
'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.
[email protected]
+def pytype(session):
+ """Run type-checking."""
+ session.interpreter = 'python3.6'
+ session.install('.',
+ 'grpcio >= 1.8.2',
+ 'grpcio-gcp >= 0.2.2',
+ 'pytype >= 2018.9.26')
+ session.run('pytype')
+
+
@nox.session
def cover(session):
"""Run the final coverage report.