Aggressive. Deterministic. Hash-Based. Brutally Honest.
pyfu is not a linter. It is a forceful Python auto-repair engine built to fix code that ordinary tools refuse to touch.
It performs syntax-first repair before formatting, using a surgical heuristic engine to recover broken files with bad indentation, missing colons, and malformed blocks β then hands them off to the formatter stack.
No lies. No loops. No mass rewrites. If nothing changed, pyfu stays silent.
-
π‘οΈ Idempotent & Hash-Based Uses SHA-256 content hashing. Ignores timestamps, mtimes, and metadata. If logic didnβt change, the file is not rewritten. Ever.
-
π Syntax Surgery Repairs
IndentationError, missing:in blocks, malformed dedents, and structurally broken code before formatting. -
π Adult Watch Mode Debounced, loop-safe, self-aware. Detects its own writes and refuses to spiral into infinite fix loops.
-
π§ͺ Auto Test Generation Generates
pytestskeletons for public functions without overwriting existing tests. -
π§° Full Formatter Arsenal Deterministically orchestrates:
ruff(unsafe fixes)autopep8(aggressive repair)pyupgradeisortblackbandit
pip install -r requirements.txtchmod +x pyfu.pyFixes Python files recursively. Silent unless it actually modifies code.
python pyfu.py .Continuously watches files and repairs on save. Loop-safe by design.
python pyfu.py . --watchFixes code and generates test_<module>.py for public functions.
python pyfu.py src/ --generate-testspython pyfu.py broken_script.pypyfu follows a strict survival-first pipeline:
-
Read & Hash Compute SHA-256. If unchanged β STOP.
-
Normalize Convert tabs β 4 spaces.
-
Syntax Check Attempt
ast.parse. -
π Surgery (if invalid)
- Inject missing colons (
if xβif x:) - Rebuild indentation hierarchy
- Repair malformed block structure
- Inject missing colons (
-
External Tools (only if needed)
ruff --fix --unsafe-fixesautopep8 -aaapyupgradeisortblack
-
Verify Re-hash. If content changed β write & report. Otherwise β silence.
pyfu will never print:
- β
Processing 10 files... - β
No changes needed - β
All files verified
pyfu only prints real events:
- π§
Repaired: <file> - π₯
Failed: <file> - π§ͺ
Generated tests: <file>
No noise. No lies.
- Python 3.10+
- Formatter tools installed and available in PATH
- The courage to let a script rewrite your bad code
pyfu is deterministic. Run it twice β the second run should do nothing.
If a tool says it fixed something, the hash must prove it.
Welcome to grown-up auto-repair.