Skip to main content

Nb Mypy is a facility to automatically run mypy on Jupyter notebook cells as they are executed, whilst retaining information about the execution history.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nb_mypy-1.0.5.tar.gz (7.3 kB view details)

Uploaded Source

File details

Details for the file nb_mypy-1.0.5.tar.gz.

File metadata

  • Download URL: nb_mypy-1.0.5.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for nb_mypy-1.0.5.tar.gz
Algorithm Hash digest
SHA256 f95244c0b9ea8e0e5924e3e5a4ad07e6c44efb9a005f902c210fed5450765c07
MD5 0532b88dc77cba981ac5130de90f42c4
BLAKE2b-256 ee1bc804ec8e3e112d098d4512e031e6382f608df66da2ab2616cd1600652149

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page