In your notebook,
using JupyterFormatter enable_autoformat()
Afterwards, whenever you run a cell, it will automatically be formatted. If you want to turn off auto-formatting, run
Jupyter Notebook and Lab Compatibility
While this package works with both legacy Jupyter Notebooks and Jupyter Lab, it does have some issues in Jupyter Notebooks. On legacy notebooks only, when a cell is formatted its output will be suppressed and it will lose its
Out. This will only happen if the cell is not already formatted properly.
For example, running this already-formatted cell will output as normal:
However, running this unformatted cell will not print properly; running this cell
Results in this formatted cell with no output
It is recommended that you run in Jupyter Lab if possible, since it does not have this issue.