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. The value of the variable doesn't matter, but we'll use 1 as an example.

export RICH_TRACEBACKS=1

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

Disabling

Unset the RICH_TRACEBACKS environment variable.

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",
    ...
}

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.

A note on the suppress option

Rich's traceback handler supports a suppress option to which you can pass an iterable of modules and paths to be excluded from tracebacks. To suppress a module, you would normally need to import the module and then pass the module object to the suppress option. For example:

import loctocat
from rich.traceback import install

install(suppress=[loctocat])

With rich-tracebacks, you also have the option of simply passing the module's name as a string. For example:

# rt_config.py

config = {
    "suppress": ["loctocat"],
    ...
}

rich-tracebacks will do the work of importing the module for you and passing the module object to Rich. Names it can't import will be passed to Rich as literal strings, which will in turn treat them as paths.

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.1.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

rich_tracebacks-1.1.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file rich_tracebacks-1.1.1.tar.gz.

File metadata

  • Download URL: rich_tracebacks-1.1.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.11.1 Linux/5.15.0-1024-azure

File hashes

Hashes for rich_tracebacks-1.1.1.tar.gz
Algorithm Hash digest
SHA256 cdcb5e092f4dde97261f49af1f7f5224fb7faa133b5a5f002ed37d79ddf164de
MD5 1dbfe9df958653f55675b08f99f72f39
BLAKE2b-256 6a7d7e0c8d9ee63fb76600277f9ceacfb2a782e58d86ea3aa6904aa12a2526ee

See more details on using hashes here.

File details

Details for the file rich_tracebacks-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: rich_tracebacks-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.11.1 Linux/5.15.0-1024-azure

File hashes

Hashes for rich_tracebacks-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5d7ad249e1dc38360e779bfe42a68e832756244c5d842e6fc8e8fe68d4522057
MD5 e45b0bb66227874eaf1dd47a83210b35
BLAKE2b-256 fc30a8cd6869113750c53d2489cf2506b5760f199728d817d51c850485718308

See more details on using hashes here.

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