Hide your ugly wrapper frames: func(*args, **kwargs)
Project description
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
)
Project details
Release history Release notifications | RSS feed
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
Hashes for hide_frames-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ff4afcf1044b442c8485182ae6c0a38f87354c4d71fa613d477e5c2364ec6db |
|
MD5 | ebc9effcdd0d426b6b09375df0177fe9 |
|
BLAKE2b-256 | b3abc6519c6573924964c9f0ca6ab9c921135dabf44bb76489cee2b2587b0a28 |