Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Added mypy to noxfile #932

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ def format(session):
)


@nox.session(python=DEFAULT_PYTHON_VERSION)
def mypy(session):
"""Verify type hints are mypy compatible."""
session.install("-e", ".")
session.install("mypy", "types-setuptools")
# TODO: also verify types on tests and logging_v2, big undertakings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are those big undertakings? logging_v2 should already have valid types in place. And I'd say tests are optional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess big is an overexaggeration, but when I ran mypy there were 22 errors in 12 files.

session.run("mypy", "-p", "google.cloud.logging", "--no-incremental")


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
Expand Down
23 changes: 23 additions & 0 deletions owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,29 @@ def place_before(path, text, *before_text, escape=None):
}""",
)

# Add mypy to noxfile.
# TODO: Remove this once this functionality gets added in synthtool
s.replace(
"noxfile.py",
"""\
@nox.session\(python=DEFAULT_PYTHON_VERSION\)
def lint_setup_py\(session\):
""",
'''\
@nox.session(python=DEFAULT_PYTHON_VERSION)
def mypy(session):
"""Verify type hints are mypy compatible."""
session.install("-e", ".")
session.install("mypy", "types-setuptools")
# TODO: also verify types on tests and logging_v2, big undertakings
session.run("mypy", "-p", "google.cloud.logging", "--no-incremental")


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
'''
)

# --------------------------------------------------------------------------
# Samples templates
# --------------------------------------------------------------------------
Expand Down