Skip to main content

Automatic installation of Rich's traceback handler

Project description

rich-tracebacks

PyPI - Python Version PyPI GitHub release (latest SemVer) PyPI - License

rich-tracebacks automates the installation of Rich's traceback handler in Python programs. Compared to Rich's own sanctioned method of automatically installing its traceback handler, rich-tracebacks is markedly simpler and agnostic to your virtual environment.

Installation

pip install rich-tracebacks

Usage

Enabling

Set the RICH_TRACEBACKS environment variable to 1.

export RICH_TRACEBACKS=1

That's it. Rich's traceback handler will be automatically installed each time you run your program.

Disabling

Set the RICH_TRACEBACKS environment variable to 0.

export RICH_TRACEBACKS=0

Alternatively, you can unset the variable entirely.

unset RICH_TRACEBACKS

Configuration

You can configure the traceback handler with its supported options by creating an rt_config.py file at your project's root. The file should contain a dictionary named config that maps option names to their intended values. For example:

# rt_config.py

config = {
    "show_locals": True,
    "width": 120,
    "theme": "monokai",
    ...
}

Of special note is the console option, which takes a Rich Console object. To use this option, you must import the Console class in your rt_config.py file. For example:

# rt_config.py

from rich.console import Console

config = {
    "console": Console(file=open("traceback.log", "w")),
    ...
}

Options that are not defined in rt_config.py will fall back to their default values. If rt_config.py does not exist, all options will fall back to their default values.

License

rich-tracebacks is licensed under the MIT License.

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

rich_tracebacks-1.0.0.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

rich_tracebacks-1.0.0-py3-none-any.whl (3.4 kB view hashes)

Uploaded Python 3

Supported by

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