Skip to content

Clean .ipynb inplace by clearing output and formatting the code with isort and black 🌻

License

Notifications You must be signed in to change notification settings

akuhnregnier/clean_ipynb

 
 

Repository files navigation

Clean IPYNB/PY

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.

1.0 Installation

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 .

2.0 Usage

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

Todo

  • 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.

About

Clean .ipynb inplace by clearing output and formatting the code with isort and black 🌻

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%