Python code formatter (and pre-commit
hook) for cell delimiters (# %%
) in VS Code-style interactive Python notebooks.
This formatter ensures
-
cell delimiters are preceded by two empty lines:
# %% before foo='bar' # %%
# %% after foo='bar' # %%
-
empty cells are removed:
# %% before # %%
# %% after
-
comments on the same line as cell delimiters are separated by a single space:
# %%some comment before foo = 'bar' # %% another comment
# %% some comment after foo = 'bar' # %% another comment
pip install format-ipy-cells
format-ipy-cells path/to/file.py
# or
format-ipy-cells **/*.py
# .pre-commit-config.yaml
repos
- repo: https://github.com/janosh/format-ipy-cells
rev: v0.1.10
hooks:
- id: format-ipy-cells