Rigby is a Python code formatter focused on managing empty lines to improve code readability. It follows a strict set of rules:
- ✨ Removes ALL empty lines within functions and classes
- 🔄 Maintains exactly one empty line between functions
- 🎯 Maintains exactly two empty lines between classes
- 🛡️ Preserves code functionality while cleaning
pip install rigby
rigby run file.py
rigby run file1.py file2.py
rigby run .
from rigby import clean_file, clean_source
clean_file("path/to/your/file.py")
source = '''
class MyClass:
def foo():
print("hello")
print("world")
def bar():
print("bar")
'''
cleaned = clean_source(source)
class MyClass:
def method1(self):
x = 1
y = 2
return x + y
def method2(self):
return True
class MyClass:
def method1(self):
x = 1
y = 2
return x + y
def method2(self):
return True
- 🧹 Smart Cleanup: Intelligently removes unnecessary empty lines while preserving code structure
- 🔍 Selective Processing: Format single files or entire directories
- 🛠️ Dual Interface: Use as a CLI tool or Python library
- ⚡ Fast Processing: Efficient parsing and formatting
- 🔒 Safe Changes: Preserves code functionality
No configuration needed! Rigby follows strict formatting rules to ensure consistency across all Python files.
Package | Version | Purpose |
---|---|---|
click | >=8.0.0 | Command line interface |
loguru | >=0.7.0 | Logging functionality |
pydantic | >=2.0.0 | Data validation |
typing-extensions | >=4.0.0 | Type hints |
rich | >=13.0.0 | Terminal output formatting |
git clone https://github.com/lothartj/rigby.git
cd rigby
pip install -e .
pytest
python -m build
python -m twine upload dist/*
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Feel free to open issues or submit pull requests.