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
- Host: GitHub
- URL: https://github.com/celsiusnarhwal/rich-tracebacks
- Owner: celsiusnarhwal
- License: mit
- Created: 2022-12-19T22:56:10.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-13T17:04:46.000Z (over 2 years ago)
- Last Synced: 2025-03-11T03:33:42.793Z (11 months ago)
- Topics: python, rich, traceback
- Language: Python
- Homepage: https://pypi.org/project/rich-tracebacks
- Size: 19.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
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.