Skip to main content

Overview

This package is created to make the debug process much easier for python projects.

Algorithm

This package imports @debug decorator for functions and methods, which:

  1. Prints all arguments taken by function and their types.
  2. Show how long is instance running in seconds.
  3. Catches and prints out detailed information about all exceptions.
  4. Prints out all returned values and their types.

Usage

  1. Import debug from clevdebug library: from clevdebug import debug
  2. Add @debug decorator to the function or method: @debug
  3. Run the script.

Examples

There are several usage cases.

Simple Example

# import debug from clevdebug
from clevdebug import debug


# Debugger for function
@debug
def foob(a, b):
    return b


# Debugger for method in class
class Boof:
    @debug
    def __init__(a, b) -> None:
        pass


if __name__ == '__main__':
    boo = Boof(1, b = 2)
    foob(1, 2)

Output is:

2022-10-29 19:27:49,521 debugger of foo                        wrapper on line         20: ========================================
2022-10-29 19:27:49,521 debugger of foo                        wrapper on line         21: Calling [<class 'function'>]foo:
2022-10-29 19:27:49,521 debugger of foo                        wrapper on line         37: There are 2 arguments:
2022-10-29 19:27:49,521 debugger of foo                        wrapper on line         40:      a: [<class 'int'>] 5
2022-10-29 19:27:49,521 debugger of foo                        wrapper on line         40:      b: [<class 'int'>] 4
2022-10-29 19:27:49,521 debugger of foo                        wrapper on line         43: Running foo takes: 0.00000
2022-10-29 19:27:49,521 debugger of foo                        wrapper on line         45: Result is: [<class 'int'>]4
2022-10-29 19:27:49,521 debugger of foo                        wrapper on line         58: ========================================
2022-10-29 19:27:49,521 debugger of __init__                        wrapper on line         20: ========================================
2022-10-29 19:27:49,521 debugger of __init__                        wrapper on line         21: Calling [<class 'function'>]__init__:
2022-10-29 19:27:49,521 debugger of __init__                        wrapper on line         37: There are 2 arguments:
2022-10-29 19:27:49,521 debugger of __init__                        wrapper on line         40:         a: [<class 'int'>] 5
2022-10-29 19:27:49,521 debugger of __init__                        wrapper on line         40:         b: [<class 'int'>] 4
2022-10-29 19:27:49,521 debugger of __init__                        wrapper on line         43: Running __init__ takes: 0.00000
2022-10-29 19:27:49,521 debugger of __init__                        wrapper on line         47: There is no return.
2022-10-29 19:27:49,521 debugger of __init__                        wrapper on line         58: ========================================

Catching errors

# import debug from clevdebug
from clevdebug import debug


# Debugger for function
@debug
def foob(a, b):
    return b/0


if __name__ == '__main__':
    foob(1, 2)

Output is:

2022-10-29 19:37:47,173 debugger of foob                        wrapper on line         20: ========================================
2022-10-29 19:37:47,173 debugger of foob                        wrapper on line         21: Calling [<class 'function'>]foob:
2022-10-29 19:37:47,173 debugger of foob                        wrapper on line         37: There are 2 arguments:
2022-10-29 19:37:47,173 debugger of foob                        wrapper on line         40:     a: [<class 'int'>] 1
2022-10-29 19:37:47,173 debugger of foob                        wrapper on line         40:     b: [<class 'int'>] 2
2022-10-29 19:37:47,174 debugger of foob                        wrapper on line         54: Exception type : ZeroDivisionError 
2022-10-29 19:37:47,174 debugger of foob                        wrapper on line         55: Exception message : division by zero
2022-10-29 19:37:47,174 debugger of foob                        wrapper on line         56: Stack trace : ['File : PATH/main.py , Line : 42, Name : wrapper, Message : result = func(*args, **kwargs)', 'File : /PATH/dev.py , Line : 6, Name : foob, Message : return b/0']
2022-10-29 19:37:47,174 debugger of foob                        wrapper on line         58: ========================================

Do not use to class

from clevdebug import debug


@debug
class A:
    def __init__(self, a, b):
        self.a = a
        self.b = b


if __name__ == '__main__':
    A(1, 2)

Output is:

TypeError: Only functions or methods INSIDE a class can be debugged

Installation

pip install clevdebug

Metadata

Release files for clevdebug 0.0.2

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

Source distribution (sdist)

Source distribution for clevdebug 0.0.2
File Size Uploaded Provenance
clevdebug-0.0.2.tar.gz 4.5 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 10.0 kB

Release files / clevdebug-0.0.2.tar.gz

Download URL clevdebug-0.0.2.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c3a140ef3ebe7cbc1d5ba01ba5590e60b66dcdc6ecc503446bac49b4a4fd2e86
BLAKE2b-256 checksum
How to use checksums
b90dba61db3d9a7333ffeca0d85a7348fb5f4f2fa04457746b21794b8a210dc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.2

Release files / clevdebug-0.0.2-py3-none-any.whl

Download URL clevdebug-0.0.2-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
595125b45721d781a1585f2cd964bb898422b30df0656b3b832d37e5c57178c0
BLAKE2b-256 checksum
How to use checksums
cdaffa74e3b01bc76271958737f738eb6e40eeb721031147abc4b352110c429a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.2

Security for clevdebug 0.0.2

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.0.2 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