IPython magic command to format python code in cell using black.
%%black
pip install blackcellmagic
git clone https://github.com/csurfer/blackcellmagic.git
python blackcellmagic/setup.py install
%load_ext blackcellmagic
# To have it formatted to black default length 88 with string normalization.
%%black
# To have it formatted to a particular line length.
%%black -l 79
%%black --line-length 79
# To skip string normalization.
%%black -S
%%black --skip-string-normalization
Tobin Jones has been kind enough to develop a NPM package over blackcellmagic to format all cells at once which can be found here.
Please use issue tracker for reporting bugs or feature requests.
Pull requests are most welcome.
If you found the utility helpful you can buy me a cup of coffee using