The uncompromising Python formatter.
Project description
True — The Uncompromising Python Formatter
True is an opinionated Python source-code formatter inspired by Black. It enforces a consistent style so you never have to think about formatting again.
Features
- Normalises string quotes (
'hello'→"hello") - Removes trailing whitespace from every line
- Enforces two blank lines before top-level
def/class - Fixes spacing around
=and binary operators - Guarantees a single trailing newline
- Pluggable rule system — extend or disable any rule
- Zero dependencies (pure stdlib)
Installation
pip install true-formatter
Or from source:
git clone https://github.com/yourname/true-formatter
cd true-formatter
pip install -e .[dev]
Quick start
As a CLI tool
# Format a file in-place
true my_script.py
# Check without modifying
true --check my_script.py
# Show a unified diff
true --diff my_script.py
# Format an entire directory
true src/
# Read from stdin
echo "x=1" | true -
As a library
import true_formatter
code = "x=1\ny= 'hello'\n"
result = true_formatter.format_str(code, mode=true_formatter.Mode())
print(result)
# x = 1
# y = "hello"
Documentation
| Document | Description |
|---|---|
| API Reference | Full public API — format_str, Mode, RuleSet, exceptions |
| CLI Reference | All command-line flags and examples |
| Architecture | How the formatter pipeline works internally |
| Contributing | Writing rules, running tests, sending PRs |
License
MIT © True Contributors
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
true_formatter-0.1.0.tar.gz
(16.0 kB
view details)
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 true_formatter-0.1.0.tar.gz.
File metadata
- Download URL: true_formatter-0.1.0.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
946a236ea70a26b8cfdf1baf58107f9cfa76c9ec0aa23e264e0668ec2aa27397
|
|
| MD5 |
3b118e6c7eeae959a082bf208961376a
|
|
| BLAKE2b-256 |
8b64fe4b6124db39b6a08ff0b556fd26e602d30e71bd55f16fcc9c13d4354d22
|
File details
Details for the file true_formatter-0.1.0-py3-none-any.whl.
File metadata
- Download URL: true_formatter-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e768c78d8fa93cfdae227a6edbee98cf3f6efc4f09ac7c9324b6a571750502e3
|
|
| MD5 |
e80bde4b90a256fffd4dd8ac0e7fee44
|
|
| BLAKE2b-256 |
cd29350f4b0e94e3d3ab6ab9fa5329919e9c8b28390a25d17843fe949beb53a4
|