An open API service indexing awesome lists of open source software.

https://github.com/celsiusnarhwal/rich-tracebacks

Automatic installation of Rich's tracebacks
https://github.com/celsiusnarhwal/rich-tracebacks

python rich traceback

Last synced: about 1 month ago
JSON representation

Automatic installation of Rich's tracebacks

Awesome Lists containing this project

README

          

# rich-tracebacks

rich-tracebacks automates the installation
of [Rich's traceback handler](https://rich.readthedocs.io/en/stable/traceback.html#traceback-handler) in Python
programs. Compared to Rich's
own [sanctioned method](https://rich.readthedocs.io/en/stable/traceback.html#automatic-traceback-handler)
of automatically installing its traceback handler, rich-tracebacks is markedly simpler and agnostic to your virtual
environment.

## Installation

```bash
pip install rich-tracebacks
```

## Usage

### Enabling

Set the `RICH_TRACEBACKS` environment variable. The value of the variable doesn't matter, but we'll use `1` as an
example.

```bash
export RICH_TRACEBACKS=1
```

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

> [!IMPORTANT]
> If you use [PyCharm](https://jetbrains.com/pycharm), you may notice that rich-tracebacks doesn't work when using
> PyCharm's debugger. You can fix this by setting the `RICH_TRACEBACKS_PYCHARM` environment variable to any value.

### Disabling

Unset the `RICH_TRACEBACKS` environment variable.

```bash
unset RICH_TRACEBACKS
```

### Configuration

You can configure the traceback handler with
its [supported options](https://rich.readthedocs.io/en/stable/reference/traceback.html#rich.traceback.install)
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:

```python
# rt_config.py

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

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.