0.1.0 • Published 5 years ago

jupyterlab-cell-formatter-black v0.1.0

Weekly downloads
51
License
BSD-3-Clause
Repository
github
Last release
5 years ago

jupyterlab-cell-formatter-black

This is modified from https://github.com/tobinjones/jupyterlab_formatblack

Formats cells using the Black uncompromising Python code formatter. This is quite a hacky solution that relies on the blackcellmagic extension by csurfer. It adds the command Format cell with Black which just 1. adds the text %%black to the top of the cell, and 2. runs the cell

You can add a keyboard shortcut by adding something like...

{
  "black:format-cell": {
    "command": "black:format-cell",
    "keys": ["F"],
    "selector": ".jp-Notebook:focus"
  }
}

... to the keyboard shortcuts in jupyterlab settings.

Prerequisites

Install

jupyter labextension install jupyterlab-cell-formatter-black

Development

For a development install (requires npm version 4 or later), do the following in the repository directory:

npm install
npm run build
jupyter labextension link .

To rebuild the package and the JupyterLab app:

npm run build
jupyter lab build