Skip to content

Commit

Permalink
Add type-checking via pytype to api_core. (#6116)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
rchen152 authored and theacodes committed Sep 27, 2018
1 parent 6a095d8 commit 65d6eba
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
16 changes: 15 additions & 1 deletion api_core/nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -108,6 +109,19 @@ 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
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.
Expand Down
7 changes: 7 additions & 0 deletions api_core/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
[bdist_wheel]
universal = 1

[pytype]
python_version = 3.6
inputs =
.
exclude =
tests/

0 comments on commit 65d6eba

Please sign in to comment.