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: v0.3.0
  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.4.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3.6

File details

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

File metadata

  • Download URL: black_nbconvert-0.4.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for black_nbconvert-0.4.0.tar.gz
Algorithm Hash digest
SHA256 7beb4a73183a8e182d2d5c96ae924862c70ae4006dba700e15b1d90fb211b4b6
MD5 3f0112da22d6f3ea6aac3009e8c98424
BLAKE2b-256 1feed9ffe39274a8dbd6b2397a29458d88d9d0417696186ac78da46d0aa07668

See more details on using hashes here.

File details

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

File metadata

  • Download URL: black_nbconvert-0.4.0-py36-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3.6
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for black_nbconvert-0.4.0-py36-none-any.whl
Algorithm Hash digest
SHA256 475befd7c04f6e3cfe859e69a71e0222a6cb730d5f841f87b2435242cafe824f
MD5 2cd6772f3f09a69055f8c5ba7f91fbd5
BLAKE2b-256 bdfe6c7fdb4198bcf4fbff5ca0c18ff102692820d199f329c6a67122b0964103

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