Smart Python traceback explainer โ understand your errors instantly
Project description
fixpy ๐
Smart Python traceback explainer โ understand your errors instantly.
fixpy analyses Python tracebacks and explains them in plain, beginner-friendly English (and Arabic!) with:
- ๐จ Beautiful Rich terminal output โ color-coded panels, syntax-highlighted code examples
- ๐ 14 exception analyzers โ SyntaxError, NameError, TypeError, AttributeError, ImportError, and more
- ๐ก Smart suggestions โ typo detection,
pip installhints, NoneType detection - ๐ Arabic mode โ
--lang arfor Arabic explanations - ๐ Watch mode โ re-analyse on every file save
- ๐ Clipboard support โ paste tracebacks directly
- ๐ง JSON output โ for CI/CD integration
- ๐ Python 3.9โ3.13 compatible
Installation
pip install fixpy
Or for development:
git clone https://github.com/yousseeff20/fixpy
cd fixpy
pip install -e ".[dev]"
Usage
Analyse a log file
fixpy error.log
Run a script and analyse its error
fixpy app.py
Pipe output directly
python app.py 2>&1 | fixpy
Paste a traceback from clipboard
fixpy --paste
Watch mode โ re-analyse on every save
fixpy --watch app.py
Arabic output
fixpy --lang ar error.log
Machine-readable JSON output
fixpy --json error.log
Example Output
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ZeroDivisionError fixpy โ Error Detected โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโ ๐ Error Location โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ File app.py โ
โ ๐ Line 5 โ
โ โ Function <module> โ
โ ๐ฌ Code result = 10 / 0 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโ ๐ What Happened โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Division by zero: used `/` with a denominator of 0. โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโ ๐ Why It Happened โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ In mathematics, dividing by zero is undefined. Python raises โ
โ ZeroDivisionError whenever the right-hand side of `/` is 0. โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโ ๐ How to Fix It โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Check that the denominator is not zero before dividing, โ
โ or use a try/except block to handle the case gracefully. โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโ โ
Fixed Code Example โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ def safe_divide(a, b): โ
โ if b == 0: โ
โ return None โ
โ return a / b โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Confidence: โโโโโโโโโโโโโโโโโโโโโ 97% (pattern-based โ not AI)
๐ถ Common Beginner Mistake
Supported Exceptions
| Exception | Confidence | Features |
|---|---|---|
SyntaxError |
88โ95% | Sub-type detection, indentation hints |
IndentationError |
95% | Tab/space mix detection |
NameError |
88% | Typo suggestions, import hints |
TypeError |
70โ90% | NoneType patterns, operand types, arg count |
AttributeError |
85โ90% | NoneType detection, per-type suggestions |
ImportError |
88% | pip install mapping for 30+ packages |
ModuleNotFoundError |
95% | Smart pip package name lookup |
IndexError |
92% | Zero-indexing explanation |
KeyError |
92% | Safe .get() pattern |
ZeroDivisionError |
97% | Guard patterns, try/except example |
ValueError |
72โ93% | int/float conversion, unpacking |
FileNotFoundError |
94% | Path tips, pathlib example |
RuntimeError |
60โ95% | Dict mutation, bare raise detection |
RecursionError |
96% | Base case explanation, function detection |
CLI Reference
Usage: fixpy [OPTIONS] [SOURCE]
fixpy โ Analyse a Python traceback and explain it in plain English.
Arguments:
[SOURCE] Path to a .py script or .log/.txt traceback file.
Options:
-p, --paste Read traceback from the system clipboard.
-w, --watch Watch a .py file โ re-analyse on every save.
-l, --lang TEXT Output language: 'en' (default) or 'ar'.
--json Output analysis as machine-readable JSON.
-v, --version Show version and exit.
--help Show this message and exit.
Building from Source
# Install build tool
pip install hatch
# Build wheel + sdist
hatch build
# Output is in dist/
ls dist/
Publishing to PyPI
# 1. Update version in pyproject.toml and src/fixpy/__init__.py
# 2. Create and push a version tag
git tag v0.1.0
git push origin v0.1.0
# GitHub Actions will automatically build and publish to PyPI
# via trusted publishing (no API keys needed).
# Or publish manually:
pip install twine
twine upload dist/*
Running Tests
# Install dev dependencies
pip install -e ".[dev]"
# Run all tests
pytest
# With coverage report
pytest --cov=fixpy --cov-report=html
# Lint
ruff check src/
Project Structure
fixpy/
โโโ src/fixpy/
โ โโโ cli.py # Typer CLI entry point
โ โโโ models.py # Core dataclasses
โ โโโ parser/ # Traceback text parser
โ โโโ analyzers/ # 14 exception analyzers + registry
โ โ โโโ exceptions/
โ โโโ formatter/ # Rich terminal renderer
โ โโโ i18n/ # English + Arabic strings
โ โโโ helpers/ # Clipboard, file watcher, similarity
โโโ tests/ # pytest test suite
โโโ examples/ # Sample .log files
โโโ .github/workflows/ci.yml # GitHub Actions CI
Contributing
See CONTRIBUTING.md.
License
MIT ยฉ fixpy 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
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 fixpy_traceback-0.1.0.tar.gz.
File metadata
- Download URL: fixpy_traceback-0.1.0.tar.gz
- Upload date:
- Size: 38.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
765ec74b5fa50cad1fc92f2e59f12a75e8aabbc04f7834fa540a3c4b91b8989b
|
|
| MD5 |
294d8058081f64850c690043393b4a41
|
|
| BLAKE2b-256 |
aea764f88c6491838ae16032b8062c7bc355b19116e180c4a0179074f483ca38
|
File details
Details for the file fixpy_traceback-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fixpy_traceback-0.1.0-py3-none-any.whl
- Upload date:
- Size: 44.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b22cccd809f5ebae8259930c2766999879f768bc78bea9277992df7f5be334a3
|
|
| MD5 |
2c079d90358c3fed4f58c68e4f1a0aca
|
|
| BLAKE2b-256 |
198f61fb45a5e96da5c8c6c49369793066531f8be5fb5f67d0c7d6771a4ef96f
|