Python implementation of Javas @throws(...) function decorator!
Project description
Python: throws
Small but simple library providing a function decorator similar to Javas @throws(...) decorator. Should maily used for annotation, documentation and debugging purposes.
Installation
Installation is possible using the Python 3 pip tool. For you the installation command possibaly looks similar to this:
pip3 install throws
Usage
To use the @throw decorator simply put it before the function declaration providing every possible exception raised by the function. For a quick example see below:
from throws import throws
@throws([IOError, ValueError])
def check_version(version_file: str) -> bool:
with open(version_file, "r", encoding = "utf-8") as vf:
if (float(vf.read() > 1.0):
return true
return false
The library provides two Exceptions by itself, the ListEmptyException and the InvalidRaisedException. The first one is raised when the list used by @throw is left blank and the function decorated is run. The second one occours when the function raises an exception which is not provided to the decorator, providing the developer with feedback that he might have forgotten about handling this specific exception!
Links
Library at the Python Package Index (PyPI): https://pypi.org/project/throws/
Project details
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
File details
Details for the file throws-1.0.2.tar.gz
.
File metadata
- Download URL: throws-1.0.2.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61456a6a002e3a0270df22932c3a2c6cd469c7e6fcab6f39db81d2850258f41e |
|
MD5 | c1369036a449a4d0256a3c5b94cf9d37 |
|
BLAKE2b-256 | e8a3ab5e7462b8f00c8a8816d65eb3654f0d04ca8c966e8cfe3e044d235044e1 |
File details
Details for the file throws-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: throws-1.0.2-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67676b9f9b3f55758204d242928b49fbe2906bcd100b2acda4139dcadb3ef51b |
|
MD5 | e8119229f858a8d5caa6b897b4af9b2a |
|
BLAKE2b-256 | b9599871532d3ae053dde9697f942586fed8496c2a26358bc6cdb8d79f1b4b4f |