Skip to content

Commit 0fce637

Browse files
rchen152theacodes
authored andcommitted
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 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 * Add a pytype session to nox.py. * Run pytype for python 3.6 only.
1 parent 58ae90e commit 0fce637

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

nox.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
from __future__ import absolute_import
1616
import os
1717

18-
import nox
18+
# https://github.com/google/importlab/issues/25
19+
import nox # pytype: disable=import-error
1920

2021

2122
@nox.session
@@ -108,6 +109,19 @@ def lint_setup_py(session):
108109
'python', 'setup.py', 'check', '--restructuredtext', '--strict')
109110

110111

112+
# No 2.7 due to https://github.com/google/importlab/issues/26.
113+
# No 3.7 because pytype supports up to 3.6 only.
114+
@nox.session
115+
def pytype(session):
116+
"""Run type-checking."""
117+
session.interpreter = 'python3.6'
118+
session.install('.',
119+
'grpcio >= 1.8.2',
120+
'grpcio-gcp >= 0.2.2',
121+
'pytype >= 2018.9.26')
122+
session.run('pytype')
123+
124+
111125
@nox.session
112126
def cover(session):
113127
"""Run the final coverage report.

setup.cfg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
[bdist_wheel]
22
universal = 1
3+
4+
[pytype]
5+
python_version = 3.6
6+
inputs =
7+
.
8+
exclude =
9+
tests/

0 commit comments

Comments
 (0)