API Reference¶
Technical reference for public modules, CLI commands, and internal core subsystems.
Public Interface¶
Public modules and entrypoints designed for direct consumption:
Package Root¶
debug_dojo
¶
Opinionated Python debugger and runner powered by dpdb and Rich.
Importing debug_dojo.install injects debugging tools into Python's builtins:
This configures dpdb as the active debugger, installs debugging helpers
(b(), p(), i(), c()), and triggers a breakpoint.
You can also invoke set_trace(), post_mortem(), or pm() directly:
Or run target scripts, modules, or commands directly from the CLI:
Modules:
| Name | Description |
|---|---|
cli |
Command-line interface for running targets with the |
install |
Install opinionated debugging tools into the current Python runtime. |
Functions:
| Name | Description |
|---|---|
pm |
Enter |
post_mortem |
Enter post-mortem debugging on the given or active exception traceback. |
set_trace |
Enter the internal DPDB debugger at the given or calling stack frame. |
pm
¶
Enter dpdb post-mortem debugging on the last unhandled exception.
Source code in src/debug_dojo/_core/debugger/session.py
post_mortem
¶
post_mortem(tb: TracebackType | None = None) -> None
Enter post-mortem debugging on the given or active exception traceback.
Args: tb (TracebackType | None): Traceback to inspect (defaults to active exc_info).
Source code in src/debug_dojo/_core/debugger/session.py
set_trace
¶
set_trace(frame: FrameType | None = None) -> None
Enter the internal DPDB debugger at the given or calling stack frame.
Args: frame (FrameType | None): Target stack frame. Defaults to the caller's frame.
Source code in src/debug_dojo/_core/debugger/session.py
In-Code Installer¶
debug_dojo.install
¶
Install opinionated debugging tools into the current Python runtime.
Command Line Interface¶
debug_dojo.cli
¶
Command-line interface for running targets with the dpdb debugger.
Classes:
| Name | Description |
|---|---|
CliArgs |
Parsed command-line arguments for Dojo. |
CliResult |
Result of running a CLI invocation in a captured buffer. |
CliRunner |
Runner for invoking |
Functions:
| Name | Description |
|---|---|
get_version |
Return the package version string. |
render_help |
Render the formatted CLI help screen using Rich panels. |
parse_cli_args |
Parse raw CLI argument strings into structured |
cli |
Execute the |
main |
Entry point for the |
CliArgs
dataclass
¶
CliArgs(
target: str | None = None,
target_args: tuple[str, ...] = (),
breaks: tuple[str, ...] = (),
show_help: bool = False,
show_version: bool = False,
error: str | None = None,
)
Parsed command-line arguments for Dojo.
Attributes: target: Target script, module, or executable to debug. target_args: Command-line arguments forwarded directly to the target. breaks: Initial breakpoint expressions armed before running the target. show_help: Flag indicating whether the help screen should be displayed. show_version: Flag indicating whether version info should be displayed. error: Validation error message if argument parsing failed.
CliResult
dataclass
¶
Result of running a CLI invocation in a captured buffer.
Attributes: exit_code: Exit status code. output: Captured combined standard and error output text.
CliRunner
¶
Runner for invoking dojo CLI commands in test and automation environments.
Args: env (Mapping[str, str] | None): Environment variables to inject during runs.
Methods:
| Name | Description |
|---|---|
invoke |
Invoke |
Source code in src/debug_dojo/cli.py
invoke
¶
Invoke app with args, capturing combined standard and error output.
Args:
app (Callable[..., int]): The CLI entrypoint function.
args (Sequence[str] | None): Arguments passed to app.
Returns: CliResult: Exit code and captured output.
Source code in src/debug_dojo/cli.py
get_version
¶
get_version() -> str
Return the package version string.
Returns:
str: Installed package version of debug-dojo, or fallback "0.10.0".
Source code in src/debug_dojo/cli.py
render_help
¶
Render the formatted CLI help screen using Rich panels.
Args: console (Console): Target Rich console for output rendering.
Source code in src/debug_dojo/cli.py
parse_cli_args
¶
Parse raw CLI argument strings into structured CliArgs.
Args: args (Sequence[str]): List of command-line argument strings.
Returns: CliArgs: Structured parsed CLI options and arguments.
Source code in src/debug_dojo/cli.py
cli
¶
cli(
args: Sequence[str] | None = None,
stdout: TextIO | None = None,
stderr: TextIO | None = None,
) -> int
Execute the dojo command-line interface.
Args:
args (Sequence[str] | None): Argument list. Defaults to sys.argv[1:].
stdout (TextIO | None): Stream for standard output. Defaults to sys.stdout.
stderr (TextIO | None): Stream for error output. Defaults to sys.stderr.
Returns: int: Exit status code (0 for success, non-zero for errors).
Source code in src/debug_dojo/cli.py
Architecture Dependency Graph¶
The internal module boundaries and import hierarchy are strictly enforced by Tach:
graph TD
debug_dojo --> debug_dojo._core
debug_dojo.__main__ --> debug_dojo.cli
debug_dojo.cli
debug_dojo._core
Internal Core Subsystems¶
Detailed API documentation for internal modules isolated under debug_dojo._core:
Debugger Subsystem¶
debug_dojo._core.debugger.debugger
¶
IPython-powered interactive debugger (DojoPdb) with Rich enhancements.
Classes:
| Name | Description |
|---|---|
DojoPdb |
Enhanced IPython debugger with Rich inspection and live frame context. |
DojoPdb
¶
Bases: TerminalPdb
flowchart TD
debug_dojo._core.debugger.debugger.DojoPdb[DojoPdb]
click debug_dojo._core.debugger.debugger.DojoPdb href "" "debug_dojo._core.debugger.debugger.DojoPdb"
Enhanced IPython debugger with Rich inspection and live frame context.
Args:
*args (object): Positional arguments forwarded to TerminalPdb.
pt_session_options (Mapping[str, object] | None): Optional
prompt_toolkit session options.
**kwargs (object): Keyword arguments forwarded to TerminalPdb.
Methods:
| Name | Description |
|---|---|
close |
Close prompt_toolkit event loop and executor resources. |
__del__ |
Ensure background loop and executor are closed on garbage collection. |
message |
Print a message to stdout unless suppressed. |
stop_here |
Return whether execution should stop at |
user_return |
Handle function return events while skipping redundant or hidden returns. |
emptyline |
Repeat |
print_stack_entry |
Print a stack entry with adaptive context lines and live variable banner. |
print_stack_trace |
Render a compact Rich call stack table followed by active frame context. |
do_context |
Set the number of source context lines shown on frame entry ( |
do_break |
Set a breakpoint or render a Rich table of active breakpoints ( |
do_continue |
Continue execution until next breakpoint ( |
do_display |
Add a watch expression or render a Rich table of watched expressions. |
do_whatis |
Display the type, MRO, and signature/size of an expression ( |
do_psource |
Render syntax-highlighted source code for an object ( |
displayhook |
Render interactive REPL expression results with Rich pretty-printing. |
do_p |
Rich-print the value of an expression ( |
do_pp |
Rich pretty-print the expanded value of an expression ( |
do_pinfo |
Provide detailed information about an object in a Rich panel ( |
do_pinfo2 |
Provide extra detailed information about an object ( |
do_args |
Display the argument list of the current function in a Rich table ( |
do_interact |
Start an interactive IPython shell in the current frame ( |
do_help |
Display the categorized command reference table or help for a command ( |
Source code in src/debug_dojo/_core/debugger/debugger.py
close
¶
Close prompt_toolkit event loop and executor resources.
Source code in src/debug_dojo/_core/debugger/debugger.py
__del__
¶
message
¶
message(msg: str) -> None
Print a message to stdout unless suppressed.
Args: msg (str): Message text to output.
stop_here
¶
Return whether execution should stop at frame during stepping.
Args: frame (FrameType): Candidate stack frame.
Returns:
bool: False when frame is hidden, otherwise superclass result.
Source code in src/debug_dojo/_core/debugger/debugger.py
user_return
¶
Handle function return events while skipping redundant or hidden returns.
Args:
frame (FrameType): Returning stack frame.
return_value (object): Value returned by frame.
Source code in src/debug_dojo/_core/debugger/debugger.py
emptyline
¶
emptyline() -> bool
Repeat lastcmd on empty Enter only when it is a safe navigation command.
Returns:
bool: Result of repeating lastcmd, or False when ignored.
Source code in src/debug_dojo/_core/debugger/debugger.py
print_stack_entry
¶
Print a stack entry with adaptive context lines and live variable banner.
Args:
frame_lineno (tuple[FrameType, int]): Target (frame, lineno) pair.
prompt_prefix (str): Prefix string forwarded to superclass.
Source code in src/debug_dojo/_core/debugger/debugger.py
print_stack_trace
¶
print_stack_trace(context: int | None = None) -> None
Render a compact Rich call stack table followed by active frame context.
Args: context (int | None): Optional context line override for the active frame.
Source code in src/debug_dojo/_core/debugger/debugger.py
do_context
¶
do_context(context: str) -> None
Set the number of source context lines shown on frame entry (context).
Args: context (str): Positive integer number of lines.
Source code in src/debug_dojo/_core/debugger/debugger.py
do_break
¶
Set a breakpoint or render a Rich table of active breakpoints (b).
Args: arg (str): Breakpoint location/condition, or empty to list breakpoints. temporary (Literal[0, 1] | bool): Whether the breakpoint is temporary.
Source code in src/debug_dojo/_core/debugger/debugger.py
do_continue
¶
Continue execution until next breakpoint (c), or evaluate c(...).
Args:
arg (str): Command argument, forwarded to evaluator when c(...).
Returns:
bool | None: Superclass return value, or None when executing c(...).
Source code in src/debug_dojo/_core/debugger/debugger.py
do_display
¶
do_display(arg: str) -> None
Add a watch expression or render a Rich table of watched expressions.
Args: arg (str): Expression to watch, or empty to list active watches.
Source code in src/debug_dojo/_core/debugger/debugger.py
do_whatis
¶
do_whatis(arg: str) -> None
Display the type, MRO, and signature/size of an expression (whatis).
Args: arg (str): Expression string to inspect.
Source code in src/debug_dojo/_core/debugger/debugger.py
do_psource
¶
do_psource(arg: str) -> None
Render syntax-highlighted source code for an object (psource).
Args: arg (str): Expression or symbol name whose source should be shown.
Source code in src/debug_dojo/_core/debugger/debugger.py
displayhook
¶
displayhook(obj: object) -> None
Render interactive REPL expression results with Rich pretty-printing.
Args: obj (object): Evaluated expression value.
Source code in src/debug_dojo/_core/debugger/debugger.py
do_p
¶
do_p(arg: str) -> None
Rich-print the value of an expression (p <expr>).
Args: arg (str): Expression string to evaluate and print.
Source code in src/debug_dojo/_core/debugger/debugger.py
do_pp
¶
do_pp(arg: str) -> None
Rich pretty-print the expanded value of an expression (pp <expr>).
Args: arg (str): Expression string to evaluate and pretty-print.
Source code in src/debug_dojo/_core/debugger/debugger.py
do_pinfo
¶
do_pinfo(arg: str) -> None
Provide detailed information about an object in a Rich panel (pinfo).
Args: arg (str): Expression or object name to inspect.
Source code in src/debug_dojo/_core/debugger/debugger.py
do_pinfo2
¶
do_pinfo2(arg: str) -> None
Provide extra detailed information about an object (pinfo2).
Args: arg (str): Expression or object name to inspect in full detail.
Source code in src/debug_dojo/_core/debugger/debugger.py
do_args
¶
do_args(arg: str) -> None
Display the argument list of the current function in a Rich table (a).
Args: arg (str): Unused command argument string.
Source code in src/debug_dojo/_core/debugger/debugger.py
do_interact
¶
do_interact(arg: str) -> None
Start an interactive IPython shell in the current frame (interact).
Args: arg (str): Unused command argument string.
Source code in src/debug_dojo/_core/debugger/debugger.py
do_help
¶
Display the categorized command reference table or help for a command (h).
Args: arg (str): Optional command or topic name.
Returns: bool | None: Superclass return value when delegating to topic handlers.
Source code in src/debug_dojo/_core/debugger/debugger.py
debug_dojo._core.debugger.breakpoints
¶
Breakpoint management, AST symbol lookup, and callable target resolution.
Functions:
| Name | Description |
|---|---|
has_active_breakpoints |
Return whether any |
debug_dojo._core.debugger.session
¶
Session lifecycle, excepthook handling, and debugger entrypoint functions.
Functions:
| Name | Description |
|---|---|
wrap_sys_excepthook |
Wrap |
set_trace |
Enter the internal DPDB debugger at the given or calling stack frame. |
setup |
Set internal DPDB as the active debugger. |
post_mortem |
Enter post-mortem debugging on the given or active exception traceback. |
pm |
Enter |
seed_cli_breakpoints |
Register CLI-supplied breakpoints before target execution. |
run_with_active_breakpoints |
Execute |
wrap_sys_excepthook
¶
Wrap sys.excepthook with _bdb_quit_excepthook once.
Source code in src/debug_dojo/_core/debugger/session.py
set_trace
¶
set_trace(frame: FrameType | None = None) -> None
Enter the internal DPDB debugger at the given or calling stack frame.
Args: frame (FrameType | None): Target stack frame. Defaults to the caller's frame.
Source code in src/debug_dojo/_core/debugger/session.py
setup
¶
Set internal DPDB as the active debugger.
post_mortem
¶
post_mortem(tb: TracebackType | None = None) -> None
Enter post-mortem debugging on the given or active exception traceback.
Args: tb (TracebackType | None): Traceback to inspect (defaults to active exc_info).
Source code in src/debug_dojo/_core/debugger/session.py
pm
¶
Enter dpdb post-mortem debugging on the last unhandled exception.
Source code in src/debug_dojo/_core/debugger/session.py
seed_cli_breakpoints
¶
Register CLI-supplied breakpoints before target execution.
Args:
target_file (str): Path to the resolved target script.
breaks (Sequence[str]): Breakpoint specifications (line, file:line, func).
Source code in src/debug_dojo/_core/debugger/session.py
run_with_active_breakpoints
¶
Execute call under dpdb trace dispatch so active breakpoints fire.
Args: call (Callable[[], object]): Zero-argument callable executing the target.
Source code in src/debug_dojo/_core/debugger/session.py
debug_dojo._core.debugger.views
¶
Visual formatting, Rich tables, and inspection panels for dpdb.
Functions:
| Name | Description |
|---|---|
is_runner_frame |
Return whether |
is_runner_frame
¶
Return whether frame belongs to an internal runner or CLI framework module.
Args: frame (FrameType): Stack frame to inspect.
Returns:
bool: True if the frame belongs to debug_dojo, runpy, bdb, typer,
or click.
Source code in src/debug_dojo/_core/debugger/views.py
Installer Subsystem¶
debug_dojo._core.installers
¶
Module for installing opinionated debugging tools into Python's builtins.
Functions:
| Name | Description |
|---|---|
install_tools |
Configure |
install_tools
¶
Configure dpdb and inject b, p, i, and c into builtins.
install_tools() import builtins all(callable(getattr(builtins, name)) for name in ("b", "p", "i", "c")) True
Source code in src/debug_dojo/_core/installers.py
Execution Subsystem¶
debug_dojo._core.execution
¶
Module for executing targets with debugging tools.
Functions:
| Name | Description |
|---|---|
execute_with_debug |
Execute a target script, module, or command with |
execute_with_debug
¶
execute_with_debug(
target_name: str, target_args: list[str], *, breaks: Sequence[str] | None = None
) -> None
Execute a target script, module, or command with dpdb and debugging tools.
Args: target_name (str): The name of the script, module, or executable to run. target_args (list[str]): Arguments to pass to the target. breaks (Sequence[str] | None): Optional CLI breakpoint specifications.
Source code in src/debug_dojo/_core/execution.py
Comparison Subsystem¶
debug_dojo._core.compare
¶
Utilities for side-by-side inspection and comparison of Python objects.
This module provides functions to display attributes and methods of two objects in a visually appealing, side-by-side format in the terminal.
Functions:
| Name | Description |
|---|---|
get_object_attributes |
Extract and format non-callable attributes of an object. |
get_object_methods |
Extract and format public callable methods of an object. |
get_simplified_object_info |
Generate a simplified, Rich-formatted inspection output for an object. |
inspect_objects_side_by_side |
Display two Python objects side-by-side in the terminal using Rich. |
get_object_attributes
¶
Extract and format non-callable attributes of an object.
Args: obj (object): The object to extract attributes from.
Returns: list[str]: A list of formatted strings, each representing an attribute.
Source code in src/debug_dojo/_core/compare.py
get_object_methods
¶
Extract and format public callable methods of an object.
Args: obj (object): The object to extract methods from.
Returns: list[str]: A list of method names.
Source code in src/debug_dojo/_core/compare.py
get_simplified_object_info
¶
Generate a simplified, Rich-formatted inspection output for an object.
Handles basic Python types by displaying their value directly. For other objects, it lists their attributes and public methods.
Args: obj (object): The object to generate info for.
Returns: list[Text]: A list of Rich Text objects representing the object's information.
Source code in src/debug_dojo/_core/compare.py
inspect_objects_side_by_side
¶
Display two Python objects side-by-side in the terminal using Rich.
Shows attributes and methods of both objects in a simplified, aligned format.
Args: obj1 (object): The first object to display. obj2 (object): The second object to display.