Nb Mypy
Nb Mypy is a facility to automatically run mypy on Jupyter notebook cells as they are executed, whilst retaining information about the execution history.
Installation
- Nb Mypy relies on the packages mypy and astor, but those should be automatically installed.
- Nb Mypy can be installed like:
python3 -m pip install nb_mypy
Once installed, you can load it via %load_ext nb_mypy in a cell of a Jupyter notebook using the IPython kernel.
Installation from source
The package can also be installed from source, using pip:
python3 -m pip install .
Usage
In Jupyter notebooks where you want to apply
automatic type checking,
you can load this extension to do type checking by executing
(in a code cell) the line magic %load_ext nb_mypy.
With the line magic %nb_mypy you can modify the behaviour of Nb Mypy
Here are the ways to use the line magic %nb_mypy
%nb_mypy -v: show version%nb_mypy: show the current state%nb_mypy On: enable automatic type checking%nb_mypy Off: disable automatic type checking%nb_mypy DebugOn: enable debug mode%nb_mypy DebugOff: disable debug mode%nb_mypy mypy-options[OPTIONS]: Provide extra options to mypy (for example --strict)
Load automatically
This package is an iPython extension, thus it can be loaded automatically by adding the following line to your iPython configuration file.
c.InteractiveShellApp.extensions = ['nb_mypy']
The configuration file can (probably) be found at ~/.ipython/profile_default/ipython_config.py or created by executing ipython profile create.
To add options, for instance, always have strict type checking on, you can add the following.
c.InteractiveShellApp.exec_lines = ['%nb_mypy mypy-options --strict']
Examples
For examples, see the Jupyter notebook Nb_Mypy.ipynb.
Release files for nb-mypy 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nb_mypy-1.0.6.tar.gz | 11.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nb_mypy-1.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.9 kB
Release files / nb_mypy-1.0.6.tar.gz
| Download URL | nb_mypy-1.0.6.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3bc0ba53442fbb05800d4529e47862602c966517b20e56542160f66943b2aa14
|
|
BLAKE2b-256 checksum How to use checksums |
33e8c3c9cef8ff4e457f40fb6349266acf81428cd1d30d2d747af5aa83f92a7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Release files / nb_mypy-1.0.6-py3-none-any.whl
| Download URL | nb_mypy-1.0.6-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d3c0426d3c84b407adaaea961f268abdae353e08044ba420918a459191c7823f
|
|
BLAKE2b-256 checksum How to use checksums |
96ea32bdae4f0f60ce907c42c413364c117fa76ef18f083e210fa566010c840d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|