Skip to main content

SmartDebug 🐍

PyPI version Python versions License

SmartDebug is a Python debugging toolkit designed to make debugging easier, faster, and more informative. It provides enhanced tracebacks, variable watching, time travel debugging, and more, giving you complete insight into your code execution.


🚀 Features

SmartDebug includes the following powerful features:

  1. Smart Tracebacks (smart_trace)

    • Enhanced traceback with:
      • Exception type and message
      • Error line with surrounding code context
      • Variable values and diffs
    • Optional parameter: use_color=True for colorized output
  2. Watch Variables (watch)

    • Monitor one or more variables in real-time
    • Prints their values whenever they are updated
  3. Why None Analysis (why_none)

    • Detect why a variable is None
    • Shows the origin of None assignments for easier debugging
  4. Variable Value Differences

    • Highlights changes in variable values before an exception
    • Works inside smart_trace to track unexpected mutations
  5. Source Context Display

    • Shows several lines of code around the error line
    • Helps understand the context of the error
  6. Colorized Output

    • Optional (use_color=True) for smart_trace
    • Highlights error lines, variable values, and context for easier reading
  7. Time Travel Debugging (time_travel)

    • Step back through execution to inspect previous variable states
    • Useful for understanding how data evolved over time
  8. Decorators

    • @trace: Automatically applies smart_trace to a function
    • @watch_vars: Automatically watches all local variables in a function
    • @time_travel_func: Captures variables for time travel inspection

📦 Installation

Install via PyPI:

pip install smartdebug

Quick Start

  1. Smart Tracebacks
from smartdebug import smart_trace

try:
    def buggy():
        nums = [1, 2, 3]
        return nums[5]  # Out of range
    buggy()
except Exception as e:
    smart_trace(e, use_color=True)

Output: Shows the line, variable values, and context around the error.

  1. Watch Variables
from smartdebug import watch

x = 10
y = 20
watch(x, y)
x += 5
y *= 2

Output: Displays changes in x and y automatically.

  1. Why None Analysis
from smartdebug import why_none

a = None
b = 5
a = b if b > 10 else None

why_none(a)

Output: Shows why a ended up being None.

  1. Time Travel Debugging
from smartdebug import time_travel_func, time_travel

@time_travel_func
def calculate():
    a = 10
    a += 5
    a *= 2
    return a

result = calculate()
time_travel('a')  # Inspect past states of `a`
  1. Decorators
from smartdebug import trace, watch_vars, time_travel_func

@trace(use_color=True)
def buggy_function():
    nums = [1, 2, 3]
    return nums[5]

@watch_vars
def update_numbers():
    x, y = 5, 10
    x += 3
    y *= 2

@time_travel_func
def calculate():
    a = 10
    a += 5
    a *= 2
    return a

Example combine demo

from smartdebug import smart_trace, watch, why_none, time_travel_func, time_travel

@time_travel_func
def demo():
    x = 5
    y = 10
    watch(x, y)
    x += 2
    y *= 3
    z = None
    why_none(z)
    nums = [1, 2, 3]
    return nums[5]  # triggers smart_trace

try:
    demo()
except Exception as e:
    smart_trace(e, use_color=True)

# Inspect variable history
time_travel('x')
time_travel('y')

Metadata

Release files for smartdebug 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smartdebug 0.2.0
File Size Uploaded Provenance Actions
smartdebug-0.2.0.tar.gz 8.7 kB Without provenance Details for smartdebug-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for smartdebug 0.2.0
File Interpreter ABI Platform Actions
smartdebug-0.2.0-py3-none-any.whl Python 3 none any Details for smartdebug-0.2.0-py3-none-any.whl

Total release size: 16.8 kB

Release files / smartdebug-0.2.0.tar.gz

Download URL smartdebug-0.2.0.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
dde7004e67ef54c4ce6b63d98d26634f75982a0b583988e5ca4f51ed7c9ed24a
BLAKE2b-256 checksum
How to use checksums
5d108a5401b7e5bb4df9fca3af2be7a822f59585967785b6296e8cbddfd8544a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.4

Release files / smartdebug-0.2.0-py3-none-any.whl

Download URL smartdebug-0.2.0-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
39397cc4c3071b8de02af78e2b3ea9d8ccdf48c1f6c08af062dc06833c8e7318
BLAKE2b-256 checksum
How to use checksums
a94ec4830594be4138a722107c598edffb3d1b1e569a46be5dbae2af169bad18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.4

Security for smartdebug 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page