Skip to content

Commit

Permalink
Add pytype nox session
Browse files Browse the repository at this point in the history
  • Loading branch information
plamut committed Sep 17, 2021
1 parent 50202e0 commit 314eb51
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pip-log.txt
.nox
.cache
.pytest_cache
.pytype


# Mac
Expand Down
11 changes: 11 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
BLACK_VERSION = "black==19.10b0"
BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]

PYTYPE_VERSION = "pytype==2021.4.9"

DEFAULT_PYTHON_VERSION = "3.8"
SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"]
UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]
Expand All @@ -41,6 +43,7 @@
"lint",
"lint_setup_py",
"blacken",
"pytype",
"docs",
]

Expand Down Expand Up @@ -169,6 +172,14 @@ def system(session):
)


@nox.session(python=DEFAULT_PYTHON_VERSION)
def pytype(session):
"""Run type checks."""
session.install("-e", ".[all]")
session.install(PYTYPE_VERSION)
session.run("pytype")


@nox.session(python=DEFAULT_PYTHON_VERSION)
def cover(session):
"""Run the final coverage report.
Expand Down
27 changes: 27 additions & 0 deletions owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,4 +351,31 @@
# ----------------------------------------------------------------------------
python.py_samples()

# ----------------------------------------------------------------------------
# pytype-related changes
# ----------------------------------------------------------------------------

# Add .pytype to .gitignore
s.replace(".gitignore", r"\.pytest_cache", "\g<0>\n.pytype")

# Add pytype config to setup.cfg
s.replace(
"setup.cfg",
r"universal = 1",
textwrap.dedent(""" \g<0>
[pytype]
python_version = 3.8
inputs =
google/cloud/
exclude =
tests/
google/pubsub_v1/ # generated code
output = .pytype/
disable =
# There's some issue with finding some pyi files, thus disabling.
# The issue https://github.com/google/pytype/issues/150 is closed, but the
# error still occurs for some reason.
pyi-error""")
)

s.shell.run(["nox", "-s", "blacken"], hide_output=False)
14 changes: 14 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,17 @@
# Generated by synthtool. DO NOT EDIT!
[bdist_wheel]
universal = 1

[pytype]
python_version = 3.8
inputs =
google/cloud/
exclude =
tests/
google/pubsub_v1/ # generated code
output = .pytype/
disable =
# There's some issue with finding some pyi files, thus disabling.
# The issue https://github.com/google/pytype/issues/150 is closed, but the
# error still occurs for some reason.
pyi-error

0 comments on commit 314eb51

Please sign in to comment.