plshandle
Create an explicit contract between caller and function that requires the caller to handle specific exceptions raised by the function.
Why
Sometimes, we just have to recover from an error. And because you are a human being, you might not always keep exception handling in mind at all times. This tool helps reduce this mental overhead by reporting all contract violations.
How
A simple example:
from plshandle import plshandle
@plshandle(KeyError)
def get_item(key):
return {}[key]
get_item(0) # tool reports this call expression as a contract violation
It is also possible to propagate errors, similar to Java:
@plshandle(KeyError)
def foo():
return get_item(0) # o.k., KeyError is propagated, caller's responsibility to handle it
Note: This tool performs static analysis only. As such, dynamic constructs are most likely not supported:
@plshandle(KeyError)
def foo():
pass
def bar(callback):
callback() # nothing reported
bar(foo)
Refer to https://plshandle.readthedocs.io for more in-depth examples.
Before committing
Fetch development dependencies
pip -r requirements-dev.txt
Ensure there are no linting errors
pylint plshandle && mypy -p plshandle
Ensure all tests are successful and code coverage is 100%
pytest && coverage report --fail-under=100
Reformat all files
black plshandle
Or just do this if you have make installed
make check
Metadata
Release files for plshandle 0.2
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 |
|---|---|---|---|---|
| plshandle-0.2.tar.gz | 13.3 kB | Without provenance | Details for plshandle-0.2.tar.gz |
Release files / plshandle-0.2.tar.gz
| Download URL | plshandle-0.2.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
12cbcc0133ac190a321ed346350ea6ed1c462a47f06ae4df871facb7d7f2f0f0
|
|
BLAKE2b-256 checksum How to use checksums |
5283131eb55bccba57a1108c72002059cb4cc8c76c326633876cd70e7395404d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.0
|
Security for plshandle 0.2
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.