Skip to main content

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)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hide_frames-1.0.1.tar.gz (38.8 kB view details)

Uploaded Source

Built Distribution

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

hide_frames-1.0.1-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

Details for the file hide_frames-1.0.1.tar.gz.

File metadata

  • Download URL: hide_frames-1.0.1.tar.gz
  • Upload date:
  • Size: 38.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for hide_frames-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3f0edff409c32c8e9a32a1b08f715afa7cb13a8c002dc7e021fbdd177fd5c323
MD5 5adfd867079b2c98eda4f348d8272162
BLAKE2b-256 61fb2db730f72fc9f81d61b47577d89e0a2f7b626807b75a6179312d43d07415

See more details on using hashes here.

File details

Details for the file hide_frames-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: hide_frames-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 27.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for hide_frames-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5ff4afcf1044b442c8485182ae6c0a38f87354c4d71fa613d477e5c2364ec6db
MD5 ebc9effcdd0d426b6b09375df0177fe9
BLAKE2b-256 b3abc6519c6573924964c9f0ca6ab9c921135dabf44bb76489cee2b2587b0a28

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page