Skip to content

Commit 0694bd4

Browse files
process: persist mypy session in noxfile (#546)
* process: persist mypy session in noxfile * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Get rid of two redundant empty lines in noxfile.py * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Add newline for better goruping of constants Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 8f32dd4 commit 0694bd4

File tree

2 files changed

+46
-6
lines changed

2 files changed

+46
-6
lines changed

noxfile.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,23 @@
5757
@nox.session(python=DEFAULT_PYTHON_VERSION)
5858
def mypy(session):
5959
"""Run type checks with mypy."""
60-
session.install("-e", ".")
60+
session.install("-e", ".[all]")
6161
session.install(MYPY_VERSION)
6262

63-
# Just install the type info directly, since "mypy --install-types" might require
64-
# an additional pass.
63+
# Just install the type info directly, since "mypy --install-types" might
64+
# require an additional pass.
6565
session.install("types-protobuf", "types-setuptools")
6666

67-
# Check the hand-written layer.
67+
# TODO: Only check the hand-written layer, the generated code does not pass
68+
# mypy checks yet.
69+
# https://github.com/googleapis/gapic-generator-python/issues/1092
6870
session.run("mypy", "google/cloud")
6971

7072

7173
@nox.session(python=DEFAULT_PYTHON_VERSION)
7274
def pytype(session):
7375
"""Run type checks."""
74-
session.install("-e", ".")
76+
session.install("-e", ".[all]")
7577
session.install(PYTYPE_VERSION)
7678
session.run("pytype")
7779

owlbot.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@
398398
s.replace(
399399
"noxfile.py",
400400
r"BLACK_PATHS = \[.*?\]",
401-
'\g<0>\n\nPYTYPE_VERSION = "pytype==2021.4.9"\n',
401+
'\g<0>\nPYTYPE_VERSION = "pytype==2021.4.9"\n',
402402
)
403403
s.replace(
404404
"noxfile.py", r'"blacken",', '\g<0>\n "pytype",',
@@ -418,8 +418,46 @@ def pytype(session):
418418
session.run("pytype")'''
419419
),
420420
)
421+
422+
# ----------------------------------------------------------------------------
423+
# Add mypy nox session.
424+
# ----------------------------------------------------------------------------
425+
s.replace(
426+
"noxfile.py",
427+
r"BLACK_PATHS = \[.*?\]",
428+
'\g<0>\n\nMYPY_VERSION = "mypy==0.910"',
429+
)
430+
s.replace(
431+
"noxfile.py", r'"blacken",', '\g<0>\n "mypy",',
432+
)
433+
s.replace(
434+
"noxfile.py",
435+
r"nox\.options\.error_on_missing_interpreters = True",
436+
textwrap.dedent(
437+
''' \g<0>
438+
439+
440+
@nox.session(python=DEFAULT_PYTHON_VERSION)
441+
def mypy(session):
442+
"""Run type checks with mypy."""
443+
session.install("-e", ".[all]")
444+
session.install(MYPY_VERSION)
445+
446+
# Just install the type info directly, since "mypy --install-types" might
447+
# require an additional pass.
448+
session.install("types-protobuf", "types-setuptools")
449+
450+
# TODO: Only check the hand-written layer, the generated code does not pass
451+
# mypy checks yet.
452+
# https://github.com/googleapis/gapic-generator-python/issues/1092
453+
session.run("mypy", "google/cloud")'''
454+
),
455+
)
456+
457+
# Only consider the hand-written layer when assessing the test coverage.
421458
s.replace(
422459
"noxfile.py", "--cov=google", "--cov=google/cloud",
423460
)
424461

462+
# Final code style adjustments.
425463
s.shell.run(["nox", "-s", "blacken"], hide_output=False)

0 commit comments

Comments
 (0)