Skip to main content

Apply black to all code cells in a jupyter notebook.

Project description

black-nb :notebook:

Build Status Code Coverage Code Style

black-nb applies black to Jupyter notebooks.

Much of the code is taken from the original black project and the behaviour is intentionally similar.

Installation

pip install black-nb

Usage

To apply black to all code cells in notebooks under the current directory:

black-nb .

To clear cell outputs in addition to reformatting:

black-nb --clear-output .

To check if notebooks pass black and additionally have no output (files will be unchanged):

black-nb --clear-output --check .

To reformat everything below ./ excluding ./outputs/* and *.ipynb_checkpoints/* :

black-nb --exclude /(outputs|\.ipynb_checkpoints)/ .

Command Line Options

black-nb doesn't provide many options. You can list them by running black-nb --help:

black-nb [OPTIONS] [SRC]...

Options:
  -l, --line-length INTEGER   Where to wrap around.  [default: 88]

  --check                     Don't write the files back, just return the
                              status.  Return code 0 means nothing would
                              change.  Return code 1 means some files would be
                              reformatted.  Return code 123 means there was an
                              internal error.

  --include TEXT              A regular expression that matches files and
                              directories that should be included on
                              recursive searches. On Windows, use forward
                              slashes for directories.  [default: \.ipynb$]

  --exclude TEXT              A regular expression that matches files and
                              directories that should be excluded on
                              recursive searches. On Windows, use forward
                              slashes for directories.  [default:
                              build/|buck-out/|dist/|_build/|\.eggs/|\.git/|
                              \.hg/|\.mypy_cache/|\.nox/|\.tox/|\.venv/|\.ipynb_checkpoints]

  --clear-output              Clearing code output is included in formatting.

  --help                      Show this message and exit.

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.4.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

black_nb-0.0.4-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: black-nb-0.0.4.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.6.3

File hashes

Hashes for black-nb-0.0.4.tar.gz
Algorithm Hash digest
SHA256 be9811ef55ac94d5e37c683c7a2f320a180f67dd6a5c853cdf5bd8cff065d68d
MD5 cdd957e478618c44427b9a58c6247484
BLAKE2b-256 ff5a5e1c37b8028b5ef67414d994529e9d025c2bc77c4c6baf23cfd0a2c8ae06

See more details on using hashes here.

File details

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

File metadata

  • Download URL: black_nb-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.6.3

File hashes

Hashes for black_nb-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a3770b206fccbf6bf64b00306e66a74586491c586d65d940ecda300195d09525
MD5 2387e805d9a19983d601d3ad424dbbb2
BLAKE2b-256 f2298e854919313ac58208565d6a8951a99b5c361b3ad8f3f3ae5a42f73c8e44

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