shrug
¯\(ツ)/¯
Sometimes an exception just isn't worth crashing over. shrug lets you shrug
it off — as a decorator or a context manager — and keeps a running tally of
how many times it's had to.
Install
pip install shrug-it
Usage
As a decorator:
from shrug import shrug
@shrug()
def risky_division(a, b):
return a / b
risky_division(1, 0) # logs a warning, returns None instead of raising
As a context manager:
from shrug import shrug
with shrug(default=[]):
data = fetch_from_flaky_api()
Only shrug off specific exceptions:
@shrug(KeyError, ValueError)
def parse(d):
return d["value"]
Give up after N shrugs and let it actually raise:
@shrug(reraise_after=3)
def flaky():
...
Check the damage:
from shrug import stats
stats() # {'count': 7}
Why
Not every failure deserves a stack trace in a demo script, a notebook, or a
best-effort background job. shrug is a small, honest way to say "eh,
whatever" without silently eating errors you actually care about — you
choose exactly which exceptions get the shrug treatment.
License
MIT
Metadata
Release files for shrug-it 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| shrug_it-0.1.0.tar.gz | 4.5 kB | Without provenance | Details for shrug_it-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| shrug_it-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for shrug_it-0.1.0-py3-none-any.whl |
Total release size: 8.7 kB
Release files / shrug_it-0.1.0.tar.gz
| Download URL | shrug_it-0.1.0.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c151ba677436a27854a2b3fadb1182a272f163141b43866d9cf29dbc9c588e80
|
|
BLAKE2b-256 checksum How to use checksums |
14cde6c15d47c1d93d3509dfd67b3a71175707716aee4b38abfdca47cc5fe3a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.2
|
Release files / shrug_it-0.1.0-py3-none-any.whl
| Download URL | shrug_it-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c18c446b1f14b36c2eadeee824c6c2bd356e5b59b584b232c7261f3a6aa8bd48
|
|
BLAKE2b-256 checksum How to use checksums |
2a81376e09c0078815dff2a49d48517387485b640a96e8eb75b074536b3d05c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.2
|
Security for shrug-it 0.1.0
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.