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.3.tar.gz (51.6 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.3-py3-none-any.whl (30.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: prism_blanklines-0.1.3.tar.gz
  • Upload date:
  • Size: 51.6 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.3.tar.gz
Algorithm Hash digest
SHA256 f1699a83f74f146f87663e10e8259868bff93cb549bbc3cc8a4af64579d66403
MD5 6986da3137058d2244380ff10bfda0f4
BLAKE2b-256 f0f821ec37ed2ed76763e23d9afd2b2c130410ce829c90d11fe1737e62106e51

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prism_blanklines-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 036b5d68274eb2a5f194e22baf44f95fcea123c08b43533141aea831573f03b4
MD5 d8ad28a7fe5a36dbce50a24f7bf5e2dd
BLAKE2b-256 a0445cf14aa61a8a86a084dd5be2f7706fe79499e15b8618dd9658538be60f4f

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