Skip to main content

Pdb with Rich library.

Project description

pdbr

PyPI version Python Version

pdbr is intended to make the PDB results more colorful. it uses Rich library to carry out that.

Installing

Install with pip or your favorite PyPi package manager.

pip install pdbr

Breakpoint

In order to use breakpoint(), set PYTHONBREAKPOINT with "pdbr.set_trace"

import os

os.environ["PYTHONBREAKPOINT"] = "pdbr.set_trace"

or just import pdbr

import pdbr

New commands

vars(v)

Get the local variables list as table.

varstree(vt)

Get the local variables list as tree.

inspect(i) / inspectall(ia)

rich.inspect

pp

rich.pretty.pprint

nn, uu, dd

Same with n(ext), u(p), d(own) commands + with local variables.

Config

Style

In order to use Rich's traceback, style, and theme, set setup.cfg.

[pdbr]
style = yellow
use_traceback = True
theme = friendly

History

store_history setting is used to keep and reload history, even the prompt is closed and opened again.

[pdbr]
...
store_history=.pdbr_history

Celery

In order to use Celery remote debugger with pdbr, use celery_set_trace as below sample. For more information see the Celery user guide.

from celery import Celery

app = Celery('tasks', broker='pyamqp://guest@localhost//')

@app.task
def add(x, y):
    
    import pdbr; pdbr.celery_set_trace()
    
    return x + y

IPython Terminal

Being able to use ipython, install pdbr with it like below or just install your own version.

pip install pdbr[ipython]

Django shell sample

Vscode user snippet

To create or edit your own snippets, select User Snippets under File > Preferences (Code > Preferences on macOS), and then select python.json.

Place the below snippet in json file for pdbr.

{
  ...
  "pdbr": {
        "prefix": "pdbr",
        "body": "import pdbr; pdbr.set_trace()",
        "description": "Code snippet for pdbr debug"
    },
}

For Celery debug.

{
  ...
  "rdbr": {
        "prefix": "rdbr",
        "body": "import pdbr; pdbr.celery_set_trace()",
        "description": "Code snippet for Celery pdbr debug"
    },
}

Samples

Traceback

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

pdbr-0.3.7.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdbr-0.3.7-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file pdbr-0.3.7.tar.gz.

File metadata

  • Download URL: pdbr-0.3.7.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.6.12 Linux/5.4.0-1039-azure

File hashes

Hashes for pdbr-0.3.7.tar.gz
Algorithm Hash digest
SHA256 9f4ab900c70e0d86ace97c05c006e775d2962a7b7c334bc58f91e2f9c4e15b98
MD5 ed529821f8f9a51ea362813fec9fa3ca
BLAKE2b-256 ec3e57c41b76c722016d1cd8dc3b6457f8d592c55636bfaf2272ac11ce1bf3f3

See more details on using hashes here.

File details

Details for the file pdbr-0.3.7-py3-none-any.whl.

File metadata

  • Download URL: pdbr-0.3.7-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.6.12 Linux/5.4.0-1039-azure

File hashes

Hashes for pdbr-0.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 5a8d7ec55066f8eac0fe06c68e3a00ad18b83c0f90d633ebd474451746d13ee8
MD5 c2a1cd37f32162286e86321308e7ac44
BLAKE2b-256 17733500cefecac5969c4cecb2d6fa42be8ad6e2e0d9fef5ec2db53bb1297737

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page