Skip to main content

jupyfmt

PyPI Tests

The uncompromising Jupyter notebook formatter.

jupyfmt allows you to format notebooks in-place from the commandline as well as assert properly formatted Jupyter notebook cells in your CI. Inspired by snakefmt. Uses black under the hood.

Installation

Install the latest release from PyPI:

$ pip install jupyfmt

Usage

jupyfmt can be used to format notebooks in-place or report diffs and summary statistics.

Overview of commandline parameters:

$ jupyfmt --help
Usage: jupyfmt [OPTIONS] [PATH_LIST]...

  The uncompromising Jupyter notebook formatter.

  PATH_LIST specifies notebooks and directories to search for notebooks in. By
  default, all notebooks will be formatted in-place. Use `--check`, `--diff`
  (or `--compact-diff`) to print summary reports instead.

Options:
  -l, --line-length INT           How many characters per line to allow.
  -S, --skip-string-normalization
                                  Don't normalize string quotes or prefixes.
  --check                         Don't write files back, just return status
                                  and print summary.
  -d, --diff                      Don't write files back, just output a diff
                                  for each file to stdout.
  --compact-diff                  Same as --diff but only show lines that
                                  would change plus a few lines of context.
  --assert-consistent-execution   Assert that all cells have been executed in
                                  correct order.
  --exclude PATTERN               Regular expression to match paths which
                                  should be exluded when searching
                                  directories.  [default: (/.git/|/.ipynb_chec
                                  kpoints/|/build/|/dist/)]
  --accepted-languages PATTERN    Only format Jupyter notebooks in these
                                  languages.  [default: python]
  --version                       Show the version and exit.
  --help                          Show this message and exit.

Report formatting suggestions for a given notebook (this is particularly useful for CI workflows):

$ jupyfmt --check --compact-diff Notebook.ipynb
--- Notebook.ipynb - Cell 1 (original)
+++ Notebook.ipynb - Cell 1 (formatted)
@@ -1,2 +1,2 @@
-def foo (*args):
+def foo(*args):
     return sum(args)

--- Notebook.ipynb - Cell 2 (original)
+++ Notebook.ipynb - Cell 2 (formatted)
@@ -1 +1 @@
-foo(1, 2,3)
+foo(1, 2, 3)

2 cell(s) would be changed 😬
1 cell(s) would be left unchanged 🎉

1 file(s) would be changed 😬

Mega-Linter Integration

jupyfmt can be run as part of Mega-Linter by adding the following to .mega-linter.yml:

PLUGINS:
  - https://raw.githubusercontent.com/kpj/jupyfmt/master/mega-linter-plugin-jupyfmt/jupyfmt.megalinter-descriptor.yml

ENABLE_LINTERS:
  - JUPYTER_JUPYFMT

Metadata

Release files for jupyfmt 0.5.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jupyfmt 0.5.3
File Size Uploaded
jupyfmt-0.5.3.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jupyfmt 0.5.3
File Interpreter ABI Platform
jupyfmt-0.5.3-py3-none-any.whl Python 3 none any Details

Total release size: 12.4 kB

Release files / jupyfmt-0.5.3.tar.gz

Download URL jupyfmt-0.5.3.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d05dc67bf86d71e58adb56342a49f1bb142f61a23639bcc99bf651b21ed65853
BLAKE2b-256 checksum
How to use checksums
8fc569af63f7a25ca920593c4a5565977f88bd918fd99579d6cd89f7fa13dcc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release files / jupyfmt-0.5.3-py3-none-any.whl

Download URL jupyfmt-0.5.3-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1fa961ccb16eb438c9479b1a28bbc918bdcc607f27b90858348e67322dcfc56f
BLAKE2b-256 checksum
How to use checksums
b44f627926580694a23042c3cf53896a51698950e062cf769fbee173cf488fd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release history Release notifications | RSS feed

This release

0.5.3 This release

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page