Auto-Reformatting with Ruff#
Panther supports automatic code reformatting using Ruff, a fast Python linter and formatter written in Rust.
Quick Setup#
To enable automatic code reformatting, set AUTO_REFORMAT
to True
in your configuration:
AUTO_REFORMAT = True # Default is False
How It Works#
When AUTO_REFORMAT
is enabled, Panther will automatically reformat your code:
- On every application run - Code is reformatted when you start your application.
- With
--reload
flag - Code is reformatted on every file change during development
This ensures your codebase maintains consistent formatting standards automatically.
Installation#
The auto-reformatting feature requires the Ruff package. Install it using pip:
pip install ruff
Configuration#
You can create a custom ruff.toml
file in your project root to configure formatting rules:
ruff.toml | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
Benefits#
- Consistent Code Style: Automatic formatting ensures all code follows the same style
- Time Saving: No need to manually format code or run formatters separately
- Team Collaboration: Everyone on the team gets consistent formatting automatically
- Fast Performance: Ruff is extremely fast, making the formatting process seamless