Skip to main content

Format iPython Cells

Tests pre-commit.ci status Requires Python 3.10+ pre-commit PyPI

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
    

Installation

pip install format-ipy-cells

Usage

CLI

format-ipy-cells path/to/file.py
# or
format-ipy-cells **/*.py

As pre-commit hook

# .pre-commit-config.yaml

repos
  - repo: https://github.com/janosh/format-ipy-cells
    rev: v0.1.10
    hooks:
      - id: format-ipy-cells

Metadata

Release files for format-ipy-cells 0.1.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for format-ipy-cells 0.1.11
File Size Uploaded
format-ipy-cells-0.1.11.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for format-ipy-cells 0.1.11
File Interpreter ABI Platform
format_ipy_cells-0.1.11-py3-none-any.whl Python 3 none any Details

Total release size: 11.2 kB

Release files / format-ipy-cells-0.1.11.tar.gz

Download URL format-ipy-cells-0.1.11.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9d2287ec9b8b661d181eec5bf31474271d0b3b02ec689341fc25227d6c9bdbf0
BLAKE2b-256 checksum
How to use checksums
4bfdca4a5575ec863ff315ef1e39207a01c3937ede88d629b4bd6bfb2a265a6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / format_ipy_cells-0.1.11-py3-none-any.whl

Download URL format_ipy_cells-0.1.11-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5c45674cfa1e7b96f5945e7cc29d4e89595f17cbd1c9f6e3462121e966f11f9d
BLAKE2b-256 checksum
How to use checksums
0a4ef48212cb72fa52de62e116abeaad565775a8cb3523a67ba4a95dff360013
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.1.11 This release

2 release files

0.1.10

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page