Skip to main content

Apply black to ipynb files

Project description

black + nbconvert

Tired of having to think about formatting in Jupyter notebooks? Look no further! This script will correctly format your Jupyter notebooks for you using black.

Warning: This project will overwrite your notebooks in place. It shouldn't change anything except the format, but use at your own risk!

Installation & Usage

To install:

pip install black_nbconvert

To check a notebook:

black_nbconvert --check /path/to/a/notebook.ipynb

To fix the formatting in a notebook (in place):

black_nbconvert /path/to/a/notebook.ipynb

If you pass a directory instead of a notebook file, notebooks will be found recursively below that directory. For example:

black_nbconvert .

will fix the formatting for all notebooks in the current directory and (recursively) below.

Configuration: Configuration for black in a pyproject.toml file above the target files will be respected.

Version control integration

Use pre-commit. Once you have it installed, add this to the .pre-commit-config.yaml in your repository:

- repo:
  rev: stable
  - id: black_nbconvert

Then run pre-commit install and you're ready to go.

Project details

Download files

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

Files for black-nbconvert, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size black_nbconvert-0.2.0-py36-none-any.whl (4.6 kB) File type Wheel Python version py36 Upload date Hashes View
Filename, size black_nbconvert-0.2.0.tar.gz (4.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page