Skip to content

Debuggable

debuggable

Module defining a protocol for debuggable objects.

Debuggable

Bases: Protocol

Protocol for objects that can provide detailed debug string representations.

Example
class Invoice(Debuggable):
    def __init__(self, number: str, total: int) -> None:
        self.number = number
        self.total = total

    def as_debug_string(self) -> str:
        return f"Invoice({self.number}, total={self.total})"


inv = Invoice("INV-001", 4200)
print(inv.as_debug_string())
Source code in src/forging_blocks/foundation/debuggable.py
class Debuggable(Protocol):
    """Protocol for objects that can provide detailed debug string representations.

    Example:
        ```python
        class Invoice(Debuggable):
            def __init__(self, number: str, total: int) -> None:
                self.number = number
                self.total = total

            def as_debug_string(self) -> str:
                return f"Invoice({self.number}, total={self.total})"


        inv = Invoice("INV-001", 4200)
        print(inv.as_debug_string())
        ```
    """

    def as_debug_string(self) -> str:
        """Return a detailed, multi-line string describing this object for debugging."""
        ...

as_debug_string() -> str

Return a detailed, multi-line string describing this object for debugging.

Source code in src/forging_blocks/foundation/debuggable.py
def as_debug_string(self) -> str:
    """Return a detailed, multi-line string describing this object for debugging."""
    ...