Skip to main content

Smart Python traceback explainer โ€” understand your errors instantly

Project description

fixpy ๐Ÿ”

Smart Python traceback explainer โ€” understand your errors instantly.

CI PyPI version Python License: MIT

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 install hints, NoneType detection
  • ๐ŸŒ Arabic mode โ€” --lang ar for 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fixpy_traceback-0.1.0.tar.gz (38.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fixpy_traceback-0.1.0-py3-none-any.whl (44.7 kB view details)

Uploaded Python 3

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

Hashes for fixpy_traceback-0.1.0.tar.gz
Algorithm Hash digest
SHA256 765ec74b5fa50cad1fc92f2e59f12a75e8aabbc04f7834fa540a3c4b91b8989b
MD5 294d8058081f64850c690043393b4a41
BLAKE2b-256 aea764f88c6491838ae16032b8062c7bc355b19116e180c4a0179074f483ca38

See more details on using hashes here.

File details

Details for the file fixpy_traceback-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fixpy_traceback-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b22cccd809f5ebae8259930c2766999879f768bc78bea9277992df7f5be334a3
MD5 2c079d90358c3fed4f58c68e4f1a0aca
BLAKE2b-256 198f61fb45a5e96da5c8c6c49369793066531f8be5fb5f67d0c7d6771a4ef96f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page