Format cells in interactive Python notebooks.
Project description
Format iPython Cells
Python code formatter (and pre-commit
hook) for cell delimiters (# %%
) in VS Code-style interactive Python notebooks.
This formatter ensures
-
cells are preceded by two empty lines:
# %% foo='bar' # %%
# %% foo='bar' # %%
-
empty cells are removed:
# %% # %%
# %%
-
same-line comments are separated by a single space:
# %%some comment foo = 'bar' # %% another comment
# %% some comment foo = 'bar' # %% another comment
Installation
pip install format-ipy-cells
Usage
CLI
format-ipy-cells path/to/file.py
# or
format-ipy-cells **/*.py
As pre-commit
hook
Add this to your .pre-commit-config.yaml
:
repos
- repo: https://github.com/janosh/format-ipy-cells
rev: v0.1.7
hooks:
- id: format-ipy-cells
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.