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.0.tar.gz (41.9 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.0-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: prism_blanklines-0.1.0.tar.gz
  • Upload date:
  • Size: 41.9 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.0.tar.gz
Algorithm Hash digest
SHA256 a6e340b96baec0cece1b6cf946fbbe8c94b9d9e0011df6db38bd2671d1f4fc26
MD5 fe6719d42899f2456468e21d69d6226d
BLAKE2b-256 a18e1d278c59817fefc635455ab03d02d4a61bc70a530dc7e7c685ea2065fb59

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prism_blanklines-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 80ec960477fe4e6b0ac545f4c7fcc9b2354b5d41aaf07ff6d680ffb3a9ab709a
MD5 eb8b2f91c9a6dc2ae10ae5980a98e207
BLAKE2b-256 01da22b1ca58a3e822e4aea1431e1ed13214accf77f47d7542f66e5f7e822e65

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