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)
- Assignment - Variable assignments, comprehensions, lambdas
- Call - Function calls, del, assert, pass, raise, yield, return
- Import - Import statements
- Control - if/for/while/try/with structures
- Definition - def/class structures
- 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
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.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prism_blanklines-0.1.1.tar.gz.
File metadata
- Download URL: prism_blanklines-0.1.1.tar.gz
- Upload date:
- Size: 45.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6d49b07f028687165abf991ee51dda20938ff6b5ca8f5d84299890c40e87031
|
|
| MD5 |
f3e0beb78d2076d3de9cc4bf49ba6e9f
|
|
| BLAKE2b-256 |
0d4d2c87da2104a9c73e5c15c9b4c95cc33584d72bddab6cbaee56cb6d787451
|
File details
Details for the file prism_blanklines-0.1.1-py3-none-any.whl.
File metadata
- Download URL: prism_blanklines-0.1.1-py3-none-any.whl
- Upload date:
- Size: 28.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64c3339bef4ef71609d479eb073b849ccf5307c838eca0058f5529ce28a51ca1
|
|
| MD5 |
bbe1406364650ef382530eb85e3278a3
|
|
| BLAKE2b-256 |
7484b0b607c0fd0a618f48f099d0ea533e1e05c5b6f79a9517b0e3f5f7f6266f
|