Apply black to all code cells in a jupyter notebook.
Project description
black-nb
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
black-nb can be installed by running pip install black-nb
. It requires
Python 3.6.0+ to run but you can reformat Python 2 code with it, too.
Usage
To apply black with a line length of 120 to all code cells in notebooks under the current directory:
black-nb . -l 120
To check if notebooks pass black, including have no output:
black-nb . -l 120 --clear-output --check
To exclude reformat everything below ./
excluding ./outputs/*
:
black-nb . -l 120 --exclude outputs
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]
Don't normalize underscores in numeric literals.
--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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file black-nb-0.0.3.tar.gz
.
File metadata
- Download URL: black-nb-0.0.3.tar.gz
- Upload date:
- Size: 5.4 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24baae4e3d16af0ba36ab0d4f67689bba9806d23b5ec107ebc22daa8057aaaa7 |
|
MD5 | 72742fa74684c9e82096942dbbcdbe29 |
|
BLAKE2b-256 | 9289303143a31c2a7c1945c94023bb83dcabf92d0ae851dd226a9cc28f316625 |
File details
Details for the file black_nb-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: black_nb-0.0.3-py3-none-any.whl
- Upload date:
- Size: 5.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71fd2d63ea8970aaed18d01fdbb8573677eefec4596e517ab708b3a924053155 |
|
MD5 | c606d6ac7075400f904bdc093b8fab49 |
|
BLAKE2b-256 | 26cb5360ab56ac88e821d4549f747c476e30cb800df024d2432c9802e7bf555c |