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

Uploaded Source

Built Distribution

black_nbconvert-0.2.0-py36-none-any.whl (4.6 kB view details)

Uploaded Python 3.6

File details

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

File metadata

  • Download URL: black_nbconvert-0.2.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for black_nbconvert-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d9698a025a8d5a3de7c56b1610dcfb183688299598cffaf32388b2e6304cf371
MD5 053d9bad815d4c32b53cf0d7bf4a95a6
BLAKE2b-256 cf082ec059df62c6547b7aee2f3d1fe850a8a2632fb7166267eb702a39aadc7c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: black_nbconvert-0.2.0-py36-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3.6
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for black_nbconvert-0.2.0-py36-none-any.whl
Algorithm Hash digest
SHA256 ef4fa3144bf186570c95652be945e0996494982a928063fbd73d9985f599d4ee
MD5 b4a49da85f78084999053f41dc54cda8
BLAKE2b-256 f969f57726cb8b304bce2a43763341740eca65929451aa266b46504dc7aab9b9

See more details on using hashes here.

Supported by

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