Watchdog-based Python auto-formatter using Ruff and Black
Project description
🧼 autofmt
A lightweight, extensible, and colorful CLI tool for automatically formatting Python files using Black and Ruff, triggered by real-time file changes via Watchdog. Ideal for developers who want instant feedback, enforced formatting, and smoother workflows.
🚀 Features
- 🎯 Watches
.pyfiles in real time - 🧹 Auto-formats using Black and Ruff
- 🧠 Runs Python syntax checks before formatting
- 🎨 Beautiful, structured logs with Rich
- 🔧 Supports user-defined config via
pyproject.toml - 📂 Designed for easy integration and extension
📦 Installation
Install using your preferred Python package manager:
With uv
uv add autofmt
With pip
pip install autofmt
⚙️ Configuration
Configure behavior directly in your pyproject.toml under [tool.autofmt]:
[tool.autofmt]
watch_path = "." # Directory to watch
formatters = ["black", "ruff"] # Tools to use
cooldown_seconds = 1.0 # Cooldown between re-runstrue)
🧠 Usage
Start the watcher
autofmt
It will:
- Watch for changes in Python files.
- Run syntax checks.
- Auto-format using Ruff and Black.
- Show you real-time logs and success/error messages.
📁 Example Output
starting autofmt watcher...
At: .
Detected change:
src/autofmt/configurations/load_config.py
Ruff logs:
src/autofmt/configurations/load_config.py
All checks passed!
Formatted path:
src/autofmt/configurations/load_config.py
Detected change:
src/autofmt/configurations/load_config.py
Detected change:
src/autofmt/configurations/load_config.py
^C
Stopping watcher...
❗ Requirements
- Python
>=3.13 - OS Independent
🧪 Testing
Run tests using:
pytest
🛠️ Planned Features
- 🧩 Plugin support for more formatters
- 🧪 Test coverage reporting
- 📊 Per-file formatter summary
- ⌨️ Command-line flags (e.g.,
--path) - 📁 Multi-folder watch support
🤝 Contributing
Contributions are welcome! Please:
- Fork the repo
- Create a branch
- Submit a PR
- Discuss features in the issues
📄 License
MIT License. See the LICENSE file for full details.
👤 Author
For questions or assistance, contact Shailesh at shaileshpandit141@gmail.com
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 autofmt-0.1.0.tar.gz.
File metadata
- Download URL: autofmt-0.1.0.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19744db97cd4f41ae44fdd89cf03efda30676762d9fc012dee18eee968c4e7bb
|
|
| MD5 |
62398d4f2d0821fd2f7fe3a15638c846
|
|
| BLAKE2b-256 |
e3f42f0d96f89d935820af04b8e3d81b1ae05b40b0aaf15ce73d67b4a36db376
|
File details
Details for the file autofmt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: autofmt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5842074e09ce2cd39d0f1d0db6e366744eb0b785f372ac9a4bf343305f55aceb
|
|
| MD5 |
75a31220a65ca479ff15b4d778f5d9b7
|
|
| BLAKE2b-256 |
fb7e0fc28701473208e2e08468920d0306746a667cadb04029e97e1977340f28
|