$ show Qix-/better-exceptions
better-exceptions is a Python library that enhances exception tracebacks by displaying the source code line and the values of local variables at each frame, with optional colorization and truncation. It hooks into Python's sys.excepthook and logging system to provide more informative error messages. The library supports automatic activation via a .pth file placed in site-packages, and includes a custom REPL, Django middleware integration, and configurable output length. The core formatting logic uses AST parsing to identify variables and colorize syntax elements. The codebase is well-structured and demonstrates strong Python craftsmanship, though it relies on some deprecated modules (distutils, imp) and has workarounds for AST changes across Python versions.
The LLM identified 2 files worth highlighting for reuse:
Provides terminal color support detection (Unix via curses, Windows via colorama) and a stream wrapper that handles encoding. Self-contained module that can be reused in any Python CLI tool needing colored output to stderr.
Custom distutils/setuptools commands to install a .pth file for automatic activation of the library upon Python startup. Demonstrates a reusable pattern for libraries that need to hook into the interpreter without explicit imports.