Skip to main content

Minimalist debug tool for Python with automatic cleaner

Project description

Siren

https://pypi.org/project/siren-debug/

Minimalist debug tool for Python.

Siren is a lightweight alternative to print / pprint, designed to work
with any Python 3 version and any framework like Django, Flask, FastAPI, or pure Python scripts.

The main goal of Siren is simple:

✔ Debug fast
✔ Trace functions automatically
✔ Measure execution time
✔ Remove debug lines automatically
✔ Work everywhere
✔ Zero dependencies


Features

  • Works in Python 3+
  • No external dependencies
  • Uses print or pprint automatically for complex objects
  • Shows file and line number
  • Optional execution timer (timeit=True)
  • Trace decorator to log function calls and returns (@siren.trace)
  • Can remove all debug calls automatically
  • Safe cleaner using Python tokenize
  • Works in Django / Flask / FastAPI / scripts / CLI
  • Colored output with emoji

Installation

Install Siren via pip:

pip install siren-debug

Then, add siren to your framework’s configuration:

# Django example
INSTALLED_APPS = [
    # ...
    "siren",
]

Usage
x = 10
data = {"a": 1, "b": [1, 2, 3]}

siren(x)
siren(data)

Output:

[🧜‍ SIREN core.py:10] x = 10
[🧜‍ SIREN core.py:11] data = {'a': 1, 'b': [1, 2, 3]}

Siren automatically uses pprint for complex objects.

Multiple values
siren(x, data, user)
Timer
siren(x, timeit=True)

Outputs the value and the elapsed time:

[🧜‍ SIREN core.py:10] x = 10
[🧜‍ SIREN TIME] 0.000123s
Trace decorator
@siren.trace
def add(a, b):
    return a + b

add(2, 3)

Output:

[🧜‍ SIREN core.py:10] Calling add
[🧜‍ SIREN core.py:11] Returned from add -> 5
Cleaner (remove all siren calls)

This is the main feature.

Remove all lines that call siren(...):

siren-clean

Example:

Before:

siren(x)
print("hello")
siren(data)

After:

print("hello")

Cleaner is safe and uses Python tokenize.
It will not remove comments or strings.

Why Siren?

Using print or pprint for debugging is easy,
but removing them later is painful.

Siren solves this.

Use:

siren(value)

And later:

siren-clean

Done.

Goals

Minimal

Safe

Cross-version

No dependencies

Easy cleanup

Works offline

Function tracing & timing

License

MIT

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

siren_debug-0.2.1.tar.gz (3.3 MB view details)

Uploaded Source

Built Distribution

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

siren_debug-0.2.1-py3-none-any.whl (4.1 MB view details)

Uploaded Python 3

File details

Details for the file siren_debug-0.2.1.tar.gz.

File metadata

  • Download URL: siren_debug-0.2.1.tar.gz
  • Upload date:
  • Size: 3.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for siren_debug-0.2.1.tar.gz
Algorithm Hash digest
SHA256 5dbc4f79bbcc80d78b2528fa379e12fbb792ee8d0f0925f907d60500925f9f32
MD5 c0d0fe4dea2014f9388f774a24c8b8c2
BLAKE2b-256 9a2e6e0c17e6da1fe1075d3161bfe383b7548236783793f478a0dc4f26cefe8a

See more details on using hashes here.

File details

Details for the file siren_debug-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: siren_debug-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 4.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for siren_debug-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ecf7d57436581f64223abd43a77cfebc61ea5c3e5e12aa5acd2a5624b13af84f
MD5 2a733d9339e9222e70c0f641b4f70f94
BLAKE2b-256 00292a221d2cfd0b1f59589f1a0edfd0bfcba75d8a20cbf356db694dffda9e68

See more details on using hashes here.

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