A simple extension for Jupyter Notebook and Jupyter Lab to beautify Python code automatically using Black.
Please note that since the Black package only supports Python 3.6+, so YAPF package will be used for the lower versions. And please DO NOT EDIT your code while running cell, otherwise your new code will be replaced by the formatted code.
You can install this package using pip:
$ [sudo] pip install nb_black
For Jupyter Notebook:
%load_ext nb_black
For Jupyter Lab:
%load_ext lab_black
Just put this code into the first cell in your Notebook, and that's all. :)