A CLI tool that explains Python errors in simple human language.
Project description
Error Translator CLI
Error Translator CLI turns Python tracebacks into clear, actionable explanations. It is a local, rule-based tool that reads the final error line, matches it against a curated regex rule set, and returns a structured translation with the original file, line number, code context, and a suggested fix.
Highlights
- Runs locally with no model inference or external API calls during normal translation.
- Supports three entry points: automatic crash interception, CLI execution, and direct traceback translation.
- Extracts file and line information from standard Python tracebacks when available.
- Includes optional AST-based insight hooks for a few error families.
- Provides both machine-readable results and colorized terminal output.
Installation
Install the published package with pip:
pip install error-translator-cli-v2
For local development or running the project from source, install the repository dependencies instead:
pip install -r requirements.txt
Usage
1. Automatic crash interception
Import error_translator.auto at the top of a script to replace Python's default exception hook with the translated output.
This is the project's magic import: once imported, any unhandled exception in that process is intercepted and formatted by the translator before Python prints the default traceback.
import error_translator.auto
maximum_user_connections = 100
print(maximum_user_connectons)
Use this when you want the translation to happen automatically without wrapping your code in a custom try/except block.
2. CLI execution
Run a script through the CLI and let the tool translate crashes from stderr.
explain-error run script.py
You can also translate a raw traceback or error string directly:
explain-error "TypeError: unsupported operand type(s) for +: 'int' and 'str'"
If you want to pipe a saved traceback into the tool, use the shell syntax for your terminal:
Get-Content error.log | explain-error
cat error.log | explain-error
3. Programmatic use
from error_translator.core import translate_error
result = translate_error(traceback_text)
print(result["explanation"])
4. HTTP API
Start the FastAPI app with Uvicorn:
uvicorn error_translator.server:app --reload
POST /translate expects JSON in the form:
{
"traceback_setting": "Traceback (most recent call last): ..."
}
What the translator returns
The translation engine returns a dictionary with these fields when available:
explanationfixmatched_errorfilelinecodeast_insight
Supported errors
The bundled rule set covers many common Python runtime, syntax, indentation, import, OS, encoding, and networking errors. The full list lives in error_translator/rules.json and can be expanded over time without changing the runtime engine.
Project layout
error_translator/core.pyloads the rule set and performs the translation.error_translator/cli.pyprovides theexplain-errorcommand.error_translator/auto.pyinstalls the automatic exception hook.error_translator/server.pyexposes the HTTP API.error_translator/ast_handlers.pycontains contextual suggestion hooks.error_translator/rules.jsonstores the rule database.
Development notes
builder.pycan generate new rule drafts with Gemini whenGEMINI_API_KEYis set.scraper.pyrefreshes the scraped exception dataset from the official Python documentation.tests/test_core.pycontains the current regression coverage for the translation engine.
Built by Gourabananda Datta.
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 error_translator_cli_v2-1.0.7.tar.gz.
File metadata
- Download URL: error_translator_cli_v2-1.0.7.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1d7491341e17248cc451857b4f06e4c47ae4d8d6d5c4e8c160264f083ca0f7b
|
|
| MD5 |
4faca0db90b7836da6c8a2a733076e22
|
|
| BLAKE2b-256 |
bdcfe6fee491054a0d0ae2400db334b8418805cb1b634181d8d0fbb324aa0544
|
File details
Details for the file error_translator_cli_v2-1.0.7-py3-none-any.whl.
File metadata
- Download URL: error_translator_cli_v2-1.0.7-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f4c3a3517ae2bb681bc242e5ca23986021cca7e8311a291151a8c52eab2f649
|
|
| MD5 |
35dfaca690c9cded0b2e9537a56912ca
|
|
| BLAKE2b-256 |
e4bfdccba18574e239f392e5a3396e3705334b22f48cc15241964454d5b807b4
|