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.

Source Distribution

black-nb-0.0.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

black_nb-0.0.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file black-nb-0.0.1.tar.gz.

File metadata

  • Download URL: black-nb-0.0.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.5

File hashes

Hashes for black-nb-0.0.1.tar.gz
Algorithm Hash digest
SHA256 117aa760c6be2cda3e870214b2504618bbc4e3434d770bc9333be8ee1ad524ab
MD5 309071565f11a31b4c1b64bb9eb20395
BLAKE2b-256 48db03d88127126f07dd0a5989271f50a6518ae8dd1aab61f3b1305d3c41a272

See more details on using hashes here.

File details

Details for the file black_nb-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: black_nb-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.5

File hashes

Hashes for black_nb-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c10c8d1d9b2c1a0ae7595588e7b9cf237edd4ff903d43f87e887399b844791d9
MD5 190f5d02c83c8ca30be62ba8fccc3090
BLAKE2b-256 250afccef870cb366751fbec08de65f0000aa5c824a36b2eca066995e8548e36

See more details on using hashes here.

Supported by

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