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:

repos:
- repo: https://github.com/dfm/black_nbconvert
  rev: stable
  hooks:
  - 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.

Source Distribution

black_nbconvert-0.3.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

black_nbconvert-0.3.0-py36-none-any.whl (4.8 kB view details)

Uploaded Python 3.6

File details

Details for the file black_nbconvert-0.3.0.tar.gz.

File metadata

  • Download URL: black_nbconvert-0.3.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for black_nbconvert-0.3.0.tar.gz
Algorithm Hash digest
SHA256 112c1050974d2ed1925738ff216d53d6ca80847eb1c727e6d017b2ba15ad4336
MD5 2019313b7f8254362174575321c60e29
BLAKE2b-256 405d8a6cf74bddc488815a62fb5758ec4a3805df8833f2ed0b0818b85e039192

See more details on using hashes here.

File details

Details for the file black_nbconvert-0.3.0-py36-none-any.whl.

File metadata

  • Download URL: black_nbconvert-0.3.0-py36-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3.6
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for black_nbconvert-0.3.0-py36-none-any.whl
Algorithm Hash digest
SHA256 5bbdedc1b0ea7ace8930ed3f375d8b7dba308c33a87709567297558c60af76d6
MD5 2a995caf1f327f9d8ae1aa0b004fd0bd
BLAKE2b-256 da9e61114fe9d281e5568fa918651d60d654679152635f956c28904d4e2cbe94

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