Skip to main content

Apply black to all code cells in a jupyter notebook.

Project description

black-nb

black-nb applies black to the code cells of Jupyter notebooks. It can be called with a list of files or directories and will search for all files ending with '.ipynb', excluding paths containing '.ipynb_checkpoints'. Additional exclusions can be added using one or more -x options (wildcards not supported), line length can be configured with -l.

Non-code cells and cells with cell magic (anything starting with '%%') will be excluded. Line magic ('%') will be treated as a comment and restored after reformatting.

Notebooks are modified inplace.

Installation

pip install git+git://github.com/tomcatling/black-nb.git#egg=black-nb

nb-black requires Python 3.6 or later.

Usage

To apply black with a line length of 88 to all notebooks under the current directory, excluding anything with 'example' in its path and 'messy.ipynb' in the current directory:

black-nb . -l 88 -x example -x ./messy.ipynb

Copyright

Copyright © 2019 Tom Catling.

black-nb is distributed under the terms of the ISC licence.

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-nb, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size black_nb-0.0.1-py3-none-any.whl (4.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size black-nb-0.0.1.tar.gz (3.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page