JupyterLab Code Formatter#

A JupyterLab plugin to facilitate invocation of code formatters.

Source Code: GitHub.

Demo#

format-all

Requirements#

  • Python 3.7+

  • JupyterLab >= 3.6.0 (if you are using JupyterLab>=3.0,<=3.5, pin this package to 2.0.0)

  • Any supported code formatters (you can also specify your own, see custom formatter).

Important

JupyterLab Code Formatter only provides an interface for invoking code formatters on Jupyter Server, and does not include any code formatter by default.

Quick Start#

  1. Install the package

pip install jupyterlab-code-formatter
poetry add jupyterlab-code-formatter
pipenv install jupyterlab-code-formatter
  1. Install some supported formatters (isort+black are default for Python)

# NOTE: Install black and isort,
#       JL code formatter is configured to invoke isort and black by default
pip install black isort
# NOTE: Install black and isort,
#       JL code formatter is configured to invoke isort and black by default
poetry add black isort
# NOTE: Install black and isort,
#       JL code formatter is configured to invoke isort and black by default
pipenv install black isort
  1. Restart JupyterLab

This plugin includes a server plugin, as suck you will need to restart JupyterLab if you have followed the above steps while it’s running.

  1. Configure plugin

To configure which/how formatters are invoked, see configuration.