Skip to main content

A CLI tool that explains Python errors in simple human language.

Project description

Error Translator

Error Translator is a Python toolkit that converts raw tracebacks into clear, actionable guidance. The project is designed for local use, deterministic output, and easy extension by contributors.

It can be used as:

  • A CLI (explain-error) for direct translation and script execution.
  • An import hook (error_translator.auto) for automatic translation of unhandled exceptions.
  • A small FastAPI service (error_translator.server) for integrations.

Why this project exists

Python's default tracebacks are precise but can be difficult for beginners and occasional Python users to act on quickly. Error Translator narrows that gap by matching final traceback lines against a curated set of regex rules and returning:

  • A plain-language explanation.
  • A concrete suggested fix.
  • Location/context metadata when available (file, line, code).
  • Optional AST-based hints for selected error families.

Key capabilities

  • Local and deterministic: no external API is required for normal translation.
  • Structured output: returns a predictable dictionary for CLI, library, and API consumers.
  • Multiple entry points: CLI, import hook, and HTTP API share the same core engine.
  • Contributor-friendly rule model: behavior is primarily driven by error_translator/rules.json.

Installation

Install from package

pip install error-translator-cli-v2

Install for local development

pip install -r requirements.txt

Usage

1) Automatic crash interception

import error_translator.auto

maximum_user_connections = 100
print(maximum_user_connectons)

Importing error_translator.auto installs a custom sys.excepthook, so unhandled exceptions are translated automatically in that process.

2) CLI mode

Run a script and translate any failure from stderr:

explain-error run script.py

Translate a single raw error string:

explain-error "TypeError: unsupported operand type(s) for +: 'int' and 'str'"

Pipe traceback text from a file:

cat error.log | explain-error

PowerShell:

Get-Content error.log | explain-error

3) Programmatic usage

from error_translator.core import translate_error

result = translate_error(traceback_text)
print(result["explanation"])

4) HTTP API

Start the API:

uvicorn error_translator.server:app --reload

POST /translate expects:

{
  "traceback_setting": "Traceback (most recent call last): ..."
}

Response contract

translate_error() returns a dictionary with these fields when available:

  • explanation
  • fix
  • matched_error
  • file
  • line
  • code
  • ast_insight

Repository structure

  • error_translator/core.py: translation pipeline and rule matching.
  • error_translator/cli.py: terminal interface (explain-error).
  • error_translator/auto.py: automatic exception-hook integration.
  • error_translator/server.py: FastAPI surface.
  • error_translator/ast_handlers.py: optional contextual heuristics.
  • error_translator/rules.json: primary rule database.
  • tests/test_core.py: regression tests for translation behavior.

Contributing

We welcome contributions of all sizes. If you are new to the project:

  1. Start with one narrowly scoped improvement.
  2. Add or update tests for behavior changes.
  3. Run pytest before submitting.
  4. Keep user-facing docs aligned with implementation.

See docs/CONTRIBUTING.md for full contributor workflow and review standards.


Maintained by Gourabananda Datta and 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

error_translator_cli_v2-1.0.9.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

error_translator_cli_v2-1.0.9-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file error_translator_cli_v2-1.0.9.tar.gz.

File metadata

  • Download URL: error_translator_cli_v2-1.0.9.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for error_translator_cli_v2-1.0.9.tar.gz
Algorithm Hash digest
SHA256 411628b30840c42c67ad7cf26273ab8cc9ef9db9f0cca5fde8a2b15afb2656cb
MD5 8ebca80e791993e09727f7cdb38ed377
BLAKE2b-256 4f592b89a2916407bd3834dcd7714a9bcf65b00241f2760449d9c3956123fe07

See more details on using hashes here.

File details

Details for the file error_translator_cli_v2-1.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for error_translator_cli_v2-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 c11a59b5962df624f6fdc41f9c5aafff989c7cf2750b663fa2bdf6abaecfa7fa
MD5 bca86184368345d1ac8b8ab24c516478
BLAKE2b-256 7442143054c318cf16871fc1638f3a3b9ffd73864e61a8807c33e29396c9174e

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