I have a project containing a bunch of Python modules (.py
files) and a bunch of Jupyter Notebooks (.ipynb
files) which import things from the Python modules.
I can (assuming I've got __init__.py
files in all subfolders) type-check all the .py
files by simply running mypy .
from the root of the project. But I'd like to also be able to type-check my Jupyter Notebooks.
An ideal solution would:
- type check all Python code in my Jupyter Notebooks,
- be able to follow imports of
.py
modules from within Jupyter Notebooks when type-checking, just like imports in.py
files, - let me type-check the whole project from the command line, so that I can run type-checking as part of a test suite or a pre-commit hook, and
- in some way meaningfully report the locations of type errors within my Notebooks, analogously to how mypy prints line numbers for errors in
.py
files.
How can I do this?