Giter VIP home page Giter VIP logo

charmed_traceback's Introduction

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()

charmed_traceback's People

Contributors

gideon-felt avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.