Skip to main content

The interactive, terminal-based object inspector for suspicious Python objects.

Project description

🔍 sus-inspector

The interactive, terminal-based object inspector for suspicious Python objects.

sus-inspector bridges the gap between the instant gratification of icecream and the deep introspection of wat. When an object in your code is acting suspicious, you don't need a heavy IDE debugger—you just need to poke it, search it, and see what's inside.

Powered by Textual and Rich.


🧠 Philosophy

  • Zero Friction: Inspecting an object should take exactly one line of code and zero setup.
  • Keyboard First: Navigating deep API responses or nested classes should be as fast as playing a terminal game.
  • Beautiful by Default: Data is easier to read when it's formatted well. sus uses a high-contrast Monokai-inspired theme, rich tables, and syntax highlighting.
  • Extensible: You can teach the debugger how to render your custom data models.

📦 Installation

pip install sus-inspector

(Note: Requires textual and rich. pydantic is natively supported if installed.)


🪄 The Magic Syntax

Import the global sus instance and drop it anywhere in your code. It blocks execution, opens the TUI, and returns the object completely untouched when you exit.

1. The Quick Inspect (/)

Borrowed from the brilliant wat inspector, the division operator allows for lightning-fast typing.

from sus_inspector import sus
import requests

response = requests.get("https://api.github.com")

# Inspect the suspicious response
sus / response

2. The Local Scope Sweep (...)

Want to know everything that is happening in the current function? Pass the Ellipsis (...) to instantly inspect all local variables in the caller's frame.

def calculate_payout(user_id):
    base_score = 42
    multiplier = 1.5

    # Wait, something is wrong here...
    sus / ...

    return base_score * multiplier

3. Standard Call

If operator overloading isn't your style, it works like a normal function, too:

sus(my_data, name="My API Payload")

4. Zero-Import Mode (Global Injection)

You can make sus available globally in your environment (no import needed) by running:

# Targets the active virtual environment (recommended)
sus --inject

# Targets the global user-site (available in all projects)
sus --inject --global

This will safely add sus to your builtins. To undo this, run:

sus --remove
# or
sus --remove --global

🎮 UI Features

  • Split-Pane Exploration: Navigate the object tree on the left (Arrow Keys); view deep, rich details on the right.
  • Smart Lazy-Loading: Only parses nested dictionaries, lists, or class attributes when you expand them, preventing terminal freezes on massive objects.
  • Breadcrumb Path Bar: A live tracker at the bottom shows your exact traversal path (e.g., dict.data.users[1].metadata.token).
  • Fuzzy Search (/): Press / to open the search bar. Type a key, press Enter, and the tree will automatically expand and jump to the first matching node.

🛠️ Extensibility (Custom View Hooks)

sus comes with a plugin system so you can define exactly how specific data types should be rendered in the Detail View.

By default, it uses rich.inspect, but it ships with native hooks for list (rendered as a truncated table) and pydantic.BaseModel (rendered as a serialized JSON tree).

You can easily register your own:

from sus_inspector import sus, register_hook
from rich.panel import Panel
import pandas as pd

def pandas_view(df: pd.DataFrame):
    """Custom view to render Pandas DataFrames cleanly."""
    summary = f"Shape: {df.shape}\nColumns: {list(df.columns)}"
    return Panel(summary, title="Pandas DataFrame", border_style="cyan")

# Teach sus how to handle DataFrames!
register_hook(pd.DataFrame, pandas_view)

sus / my_messy_dataframe

🏗️ Architecture

To move from a single-file prototype to a maintainable package, the codebase will be split into the following structure:

sus-inspector/
├── pyproject.toml
└── src/sus_inspector/
    ├── __init__.py       # Exports `sus`, `register_hook`
    ├── core.py           # Contains the `InteractiveExplorer` class and operator magic
    ├── tui/
    │   ├── app.py        # Textual UI application
    │   ├── styles.tcss   # External styles
    │   └── widgets.py    # Custom widgets
    ├── search.py         # Search logic
    └── hooks/
        ├── __init__.py   # Hook registry
        ├── builtins.py   # list, dict, set renderers
        └── pydantic.py   # Pydantic support

🗺️ Current Roadmap

  • Operator Overloading API (sus / obj)
  • Local Frame Inspection (sus / ...)
  • Basic Search functionality
  • Refactor prototype into modular architecture
  • Visual toggle (d) to show/hide private __dunder__ methods
  • Support for evaluating simple expressions in search bar

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

sus_inspector-0.1.0.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

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

sus_inspector-0.1.0-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file sus_inspector-0.1.0.tar.gz.

File metadata

  • Download URL: sus_inspector-0.1.0.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sus_inspector-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ed43f2dfb02c9cb257732a82a32e168cf0545e3dd917dfba3882797762c90fa0
MD5 4f81e860e469b36a9035b08011cf24c5
BLAKE2b-256 f01112a4a325f4519016944d73583e67ca1289ebd2d6e954a7ccfaadced125ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for sus_inspector-0.1.0.tar.gz:

Publisher: publish.yml on bwrob/sus-inspector

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sus_inspector-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sus_inspector-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sus_inspector-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 936042cc79d1117e3c92e78a61a820afbd95e877e612412d8b92a724525fab60
MD5 017ee804ffaa3590afc7f47141b0f6df
BLAKE2b-256 1ee5b2af425b69ec3048f0507d24bb20b0638971dab2b7aa163609234307fa74

See more details on using hashes here.

Provenance

The following attestation bundles were made for sus_inspector-0.1.0-py3-none-any.whl:

Publisher: publish.yml on bwrob/sus-inspector

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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