Small CLI program capable of cleaning .ipynb
and .py
sources. Tidy and remove redundant imports (via autoflake), sort imports (via isort), lint and standardize (via black). Apply equally to entire .py
or .ipynb
files. Additionally, clear all .ipynb
cell outputs and execution counts (squeeze those diffs!). Forked from KwatMe's orginal repo.
Via git pip:
pip install git+https://github.com/KwatME/clean_ipynb
Via source:
git clone https://github.com/KwatME/clean_ipynb
cd clean_ipynb
pip install .
Clean .ipynb
source:
clean_ipynb a_single_notebook.ipynb
Or .py
source:
clean_ipynb a_single_script.py
Or an entire directory recursively:
clean_ipynb <some_dir_containing_py_ipynb_source>
Or a list of files and directories:
clean_ipynb a_single_script.py <some_dir_containing_py_ipynb_source>
Clean without specific features if necessary (uses all features by default):
clean_ipynb <some_dir_containing_py_ipynb_source> --no-black --no-autoflake
A full list of parameters can be found via:
clean_ipynb --help
- Unit tests. Null parameter, invalid parameter edge cases etc.
- Read from standard input and write to standard output. Exhibit behaviour analogous to other tools such as black which do this if
-
is used as a filename.