Skip to content

Overview

debug dojo

🏣 debug dojo, a place for zen debugging

PyPi Version PyPI pyversions downloads license pre-commit.ci status

debug-dojo is a standalone, opinionated Python debugger and script runner powered by dpdb. It combines an IPython debugging shell with rich terminal panels, inline variable change tracking, post-mortem crash inspection, and built-in shortcuts for side-by-side object comparison.

# Run any script directly with uvx — zero configuration requireduvx debug-dojo app.py
╭─────────────────────────────── <class 'dict'> ───────────────────────────────╮
│ {'service': 'api', 'port': 8080, 'active': True} │
╰──────────────────────────────────────────────────────────────────────────────╯
# Breakpoints stop in dpdb with inline variable contextn> /workspace/app.py(12)<module>()
10 service = {"service": "api", "port": 8080}
11 b()
----> 12 result = handle_request(service)
↳ Line: service={'service': 'api', 'port': 8080}
c

Key Features

  • Zero-Config Runner (uvx debug-dojo script.py): Run scripts, modules, or commands immediately. Automatically discovers your project's .venv and leaves no configuration files, cache, or history behind.
  • Built-in dpdb Debugger: Extends IPython's terminal debugger with Rich call stacks (w), function argument tables (a), object inspection (pinfo, whatis, psource), adaptive source context, and a live bottom keybinding toolbar.
  • Inline Frame Context Banner: Displays modified local variables (Δ Changed:), active-line variable values (↳ Line:), return values (↩ Return:), and watched expressions (👁 Watch:) on every step.
  • Opinionated Debugging Helpers: Call b() (breakpoint), p() (pretty print), i() (inspect object), and c() (side-by-side compare) anywhere in your code.
  • Rich Tracebacks & Post-Mortem: Formats unhandled exceptions with highlighted source context and enters a dpdb post-mortem session at the crash location.

Quick Start

1. Run with the CLI

Execute scripts, modules, or test runners directly:

# Run a Python script with uvx
uvx debug-dojo script.py

# Run with the installed dojo alias
dojo script.py

# Run an importable Python module
dojo my_package.worker

# Run an executable command with debugging tools active
dojo pytest

# Set initial breakpoints from the CLI
dojo -b 42 -b handle_request app.py

2. In-Code Activation

Import debug_dojo.install anywhere in your code to configure dpdb and inject helper tools into Python's builtins:

import debug_dojo.install

# Inspect, compare, and break
data_a = {"user": "alice", "roles": ["admin"]}
data_b = {"user": "alice", "roles": ["viewer"]}

p(data_a)  # Pretty print with Rich
i(data_a)  # Inspect attributes and methods
c(data_a, data_b)  # Side-by-side comparison table
b()  # Trigger dpdb breakpoint

Injected Helper Functions

Shortcut Description Underlying Implementation
b() Trigger breakpoint debug_dojo.set_trace via breakpoint()
p(obj) Pretty-print object rich.print(obj)
i(obj) Detailed inspection rich.inspect(obj, methods=True, private=True)
c(obj1, obj2) Side-by-side comparison debug_dojo._core.compare.inspect_objects_side_by_side

Installation

Run directly without installation using uvx:

uvx debug-dojo script.py

Or install into a virtual environment with uv:

uv pip install debug-dojo