Skip to content

Traceback intercept hook, providing applying Jetbrains style traceback highlighting, providing much easier debugging and log searching.

Notifications You must be signed in to change notification settings

Gideon-Felt/charmed_traceback

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Charmed Traceback

JetBrains style Tracebacks everywhere.
Automatically apply traceback styling akin to Jetbrains Traceback highlighting, providing much easier debugging and log searching, as-well as feel more at home away from PyCharm

Installation

Through pip:

pip install charmed-traceback

Build with poetry:

pip install Poetry
poetry build

Usage

Charmed Traceback can be executed as a module:

python -m charmed_traceback somefile.py

Charmed Traceback also works well within a script or even directly in the interpreter REPL. Standard usage will re-stylize the output, unless it's being redirected to a pipe:

import charmed_traceback
charmed_traceback.add_hook()

If want to retain the charmed style even when stderr is being piped, tack on an always=True argument:

import charmed_traceback
charmed_traceback.add_hook(always=True)

There are also a couple of convenience imports, which get the footprint down to one line:

# Same as add_hook()
import charmed_traceback.auto

# Same as add_hook(always=True)
import charmed_traceback.always

When implementing with a project that alternates between having access to development dependencies and not having those dependencies, it would be most convenient to provide a context manager to use this Charmed Tracebacks:

import contextlib

def dev_charm_traceback_handler() -> None:
    with contextlib.suppress(ImportError):
        import charmed_traceback.auto

# This call can be left in a project regaurdless of the presence of Charmed Traceback package.
dev_charm_traceback_handler()

About

Traceback intercept hook, providing applying Jetbrains style traceback highlighting, providing much easier debugging and log searching.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages