tools to assist with debug
Project description
pusher_debug
pusher_debug.tracing
Tools to aid in adding print statements to trace program flow:
ObjWatchfrom the objwatch libraryDetailWrapper, a "wrapper" to use with Objwatch that provides more details on function calls and returns, and can be subclassed easily to provide distinct id strings for different instances of selected classes.fn_name,fn_entry, andfn_exit, to provide manual logging of details of function you enter (caller, parameters, return value, annotations)
pusher_debug.monkeypatching
Tools to aid in monkeypatching. Two decorators:
@add_new_class(ExistingClass)
class MyClass: ...
will (in the module where ExistingClass is defined)
- Create
orig_ExistingClass, as a backup ofExistingClass - Create
new_ExistingClass, as a backup ofMyClass - Make
ExistingClassbenew_ExistingClass(fixing__name__and__qualname__betweennew_ExistingClassandorig_ExistingClassas well)
Then restore_class(ExistingClass) will restore the original, and restore_new_class(ExistingClass) will put back the new version again.
@add_to_class(ExistingClass)
def fn():...
will (in ExistingClass) add a method fn. If fn already exists, the the original is backed up as orig_fn. new_fn is created and names are fixed as for @add_new_class.
@add_to_class can be combined with one of @classmethod, @staticmethod, or @property (and if property, then fn in the local namespace will be the property, so you can then do
@add_to_class(ExistingClass)
@fn@setter
def fn():...
You should know that monkeypatching will wreack havoc with mypy, since it does stuff you shouldn't do. (It's for debugging !)
For examples, use help(...), and/or download the source package and look at the tests. Seeing all the # test: ignore[] stuff in the test program gives you an idea of how much mypy hates this.
The library can be built with hatchling build, tested with tests/test_tools.py -v, and should pass mypy (including having annotations for objwatch).
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pusher_debug-1.1.0.tar.gz.
File metadata
- Download URL: pusher_debug-1.1.0.tar.gz
- Upload date:
- Size: 34.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1a5d5e373d30633ea39c73402f4c8144fa9c5925a61f92d431466cfe55fc2e0
|
|
| MD5 |
66a1209524db7c1785383a970f6b08be
|
|
| BLAKE2b-256 |
60888175e032298074801d9d86a54eb60961a6f8fd20e42cf5ae2fafcf672a13
|
File details
Details for the file pusher_debug-1.1.0-py3-none-any.whl.
File metadata
- Download URL: pusher_debug-1.1.0-py3-none-any.whl
- Upload date:
- Size: 30.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
150ae9278f368c61015a1730351e398f31fde7ebab44409a87b4721c294e4f43
|
|
| MD5 |
ca905d9e060252248e035e8f9f943de2
|
|
| BLAKE2b-256 |
d9caf973fe0bc5d105966aeab098ad500a6171521ec19710292068cf556eccc5
|