Skip to content

Use the 'rich' package to create more detailed exception tracebacks #3504

Open
@whart222

Description

@whart222

Summary

Use the rich package to create detailed traceback messages

Rationale

Python tracebacks are hard to parse and often not sufficiently informative to support debugging. The 'rich' package includes facilities for generating detailed tracebacks that are (1) easy to read, and (2) show the values of local variables.

Description

I recently saw a really nice traceback generated when running pip with the --debug option. I tracked this down to the rich package. Looking at the pip package (see https://github.com/pypa/pip/blob/29cd0c4eb72458c946ca5d681a3a3a74a015a0d9/src/pip/_vendor/rich/_extension.py#L7), I think the following is enough to setup rich tracebacks:

import rich.traceback
rich.traceback.install(show_locals=True)

See the rich documentation: https://rich.readthedocs.io/en/stable/traceback.html

I'm not sure where it makes sense to include this import, though.

Additional information

None.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions