Skip to main content

Blank line enforcement for Python code based on CLAUDE.md rules

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

Prism

A Python code formatter that enforces blank line rules defined in CLAUDE.md.

Features

  • Two-pass architecture: Clean separation between code analysis and rule application
  • Multiline statement support: Properly handles statements spanning multiple lines
  • Assignment precedence: x = func() classified as Assignment (not Call)
  • Secondary clause handling: No blank lines before elif/else/except/finally
  • Comment break rules: Comments cause block breaks with specific blank line rules
  • Recursive indentation: Independent rule application at each nesting level
  • Change detection: Only modifies files that actually need changes

Installation

pip install -e .

Usage

# Format files
prism file.py
prism src/

# Check if files need formatting
prism --check file.py

# Show help
prism --help

CLAUDE.md Rules

Prism enforces the complex blank line rules defined in CLAUDE.md:

Block Types (in precedence order)

  1. Assignment - Variable assignments, comprehensions, lambdas
  2. Call - Function calls, del, assert, pass, raise, yield, return
  3. Import - Import statements
  4. Control - if/for/while/try/with structures
  5. Definition - def/class structures
  6. Declaration - global/nonlocal statements

Key Rules

  • Blank lines between different block types
  • Consecutive Control/Definition blocks need separation
  • No blank lines before secondary clauses (elif, else, except, finally)
  • Comments cause block breaks and need preceding blank lines
  • Rules applied independently at each indentation level

Architecture

├── src/prism/
│   ├── __init__.py
│   ├── cli.py              # Command line interface
│   ├── analyzer.py         # Pass 1: File structure analysis
│   ├── rules.py            # Pass 2: Blank line rule engine
│   ├── parser.py           # Multiline statement parsing
│   ├── classifier.py       # Statement classification
│   └── processor.py        # File I/O and change detection
├── tests/
│   ├── test_analyzer.py
│   ├── test_rules.py
│   ├── test_parser.py
│   └── test_integration.py
└── docs/
    └── rules.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prism_blanklines-0.1.2.tar.gz (47.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prism_blanklines-0.1.2-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

Details for the file prism_blanklines-0.1.2.tar.gz.

File metadata

  • Download URL: prism_blanklines-0.1.2.tar.gz
  • Upload date:
  • Size: 47.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for prism_blanklines-0.1.2.tar.gz
Algorithm Hash digest
SHA256 92e707d49b937ae94d358f20985efa88a3caaff0de5ec25ad00b3f6162f5566b
MD5 50f18c5a3a2fe1dae50f637adb88f260
BLAKE2b-256 5b0b86f1a1bb9535021d6937c4ce9b1780339a8bc3d922ba843408bd5e7da85a

See more details on using hashes here.

File details

Details for the file prism_blanklines-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for prism_blanklines-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 084437150c2169d96d9cd555cecda016d937649db043a616353c348d1cf0d8c7
MD5 19b0409b7bfb154ab17dbad9fcf9f79c
BLAKE2b-256 4a954592671b72d980a428267354451ae37618c41e47154649bf4d1d1330297f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page