Skip to content

Commit 1fcec75

Browse files
committed
test: add mypy type checking
1 parent d20da04 commit 1fcec75

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

bigquery_magics/bigquery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
try:
109109
from google.cloud import bigquery_storage # type: ignore
110110
except ImportError:
111-
bigquery_storage = None
111+
bigquery_storage = None # type: ignore
112112

113113
IPYTHON_USER_AGENT = "ipython-{}".format(IPython.__version__)
114114
context = bigquery_magics.config.context

noxfile.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,25 @@ def lint_setup_py(session):
167167
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
168168

169169

170+
@nox.session(python=DEFAULT_PYTHON_VERSION)
171+
def mypy(session):
172+
"""Run type checks with mypy."""
173+
session.install(".")
174+
session.install("mypy")
175+
176+
# Just install the dependencies' type info directly, since "mypy --install-types"
177+
# might require an additional pass.
178+
session.install(
179+
"types-protobuf",
180+
"types-python-dateutil",
181+
"types-requests",
182+
"types-setuptools",
183+
)
184+
185+
shutil.rmtree(".mypy_cache", ignore_errors=True)
186+
session.run("mypy", "-p", "bigquery_magics", "--show-traceback")
187+
188+
170189
def install_unittest_dependencies(session, *constraints):
171190
standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES
172191
session.install(*standard_deps, *constraints)

0 commit comments

Comments
 (0)