hide_frames
Ever had nested wrappers (probably from many libraries) ... and your traceback look messy? There's just func(*args, **kwargs) everywhere!
Not anymore, using hide_frames, you can (ironically) use a simple decorator to hide your ugly frames!
Installation
pip install hide_frames
Example
Suppose we have a wrapper:
def useless(f):
def wrapped_function(*args, **kwargs):
return f(*args, **kwargs)
return wrapped_function
If we have a function that raises an exception and we wrap it:
@useless
def oops():
raise Exception
We would get an ugly traceback if we call it:
Traceback (most recent call last):
File "myfile.py", line 10, in <module>
oops()
File "myfile.py", line 3, in wrapped_function
return f(*args, **kwargs) # <--- ugly
^^^^^^^^^^^^^^^^^^
File "myfile.py", line 8, in oops
raise Exception
Exception
We can use the hide_frame decorator to modify our useless decorator:
def useless(f):
@hide_frame # <-- important
def wrapped_function(*args, **kwargs):
return f(*args, **kwargs)
return wrapped_function
Now, our traceback looks like this:
Traceback (most recent call last):
File "myfile.py", line 13, in <module>
oops()
File "myfile.py", line 11, in oops
raise Exception
Exception
Hooray! No more f(*args, **kwargs) !
The best part: it works with any number of decorators!
If you have more than one frame that needs to be hidden, use hide_nframes()
(There's another simple example in test.py)
Metadata
Release files for hide-frames 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hide_frames-1.0.1.tar.gz | 38.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hide_frames-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 65.9 kB
Release files / hide_frames-1.0.1.tar.gz
| Download URL | hide_frames-1.0.1.tar.gz |
|---|---|
| Size | 38.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f0edff409c32c8e9a32a1b08f715afa7cb13a8c002dc7e021fbdd177fd5c323
|
|
BLAKE2b-256 checksum How to use checksums |
61fb2db730f72fc9f81d61b47577d89e0a2f7b626807b75a6179312d43d07415
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.2
|
Release files / hide_frames-1.0.1-py3-none-any.whl
| Download URL | hide_frames-1.0.1-py3-none-any.whl |
|---|---|
| Size | 27.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5ff4afcf1044b442c8485182ae6c0a38f87354c4d71fa613d477e5c2364ec6db
|
|
BLAKE2b-256 checksum How to use checksums |
b3abc6519c6573924964c9f0ca6ab9c921135dabf44bb76489cee2b2587b0a28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.2
|