Skip to main content

🧼 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 .py files 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:

  1. Watch for changes in Python files.
  2. Run syntax checks.
  3. Auto-format using Ruff and Black.
  4. 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:

  1. Fork the repo
  2. Create a branch
  3. Submit a PR
  4. 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

Metadata

Release files for autofmt 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autofmt 0.1.1
File Size Uploaded
autofmt-0.1.1.tar.gz 13.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for autofmt 0.1.1
File Interpreter ABI Platform
autofmt-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.9 kB

Release files / autofmt-0.1.1.tar.gz

Download URL autofmt-0.1.1.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5e15e01672bf696e52c128896734d72b5368adcbcbc2838309e24c4bb429f74c
BLAKE2b-256 checksum
How to use checksums
c355bc58f0b5a922a4bb8dbdb8c47e02aa30bc9450710fc9d64b77f351f96b50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.6

Release files / autofmt-0.1.1-py3-none-any.whl

Download URL autofmt-0.1.1-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7f8a194b2d54d0bfad1e4dabd774ce37ef794e7fda4e4f81ce51ed031c119d2e
BLAKE2b-256 checksum
How to use checksums
0961eb08514b768fcd17ac27b2de237c4b9c480562a611d33dc147ec6ef9223b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.6

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page