A simple library for decorating functions that can raise exceptions.
Project description
can-raise
A simple library for decorating functions that can raise exceptions.
Installation
pip install can-raise
Usage
from can_raise import can_raise
@can_raise(ValueError)
def validate_int(x: int):
if x < 0:
raise ValueError
return x
If you don't provide any value, it will default to Exception
@can_raise()
def raise_exc():
raise TypeError # or any other exception
You can also provide more than one argument
@can_raise(ValueError, TypeError)
def raise_exc(x: int):
if x < 0:
raise ValueError
if x > 0:
raise TypeError
return x
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
can_raise-0.2.1.tar.gz
(8.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file can_raise-0.2.1.tar.gz.
File metadata
- Download URL: can_raise-0.2.1.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b71a1086f402bb8705ed17689cbdb5e30fcf338ca6fe87e9ac6bc7bf491aafb
|
|
| MD5 |
000e6b49e3f67342c26c3680751a7589
|
|
| BLAKE2b-256 |
8733ad654f25eb6c977abaac942c4ecdcfa0d203fb34bcf6e3033f8d5fa34496
|
File details
Details for the file can_raise-0.2.1-py3-none-any.whl.
File metadata
- Download URL: can_raise-0.2.1-py3-none-any.whl
- Upload date:
- Size: 2.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b01e7717e7a26ffe48dfd4f2bdd6e87bdeb7066522da9b3ee9bacf2224cd6b0c
|
|
| MD5 |
f0f103be7ffc6991174f4a52c88b0bd2
|
|
| BLAKE2b-256 |
f701c7c589ab334f5cdf4bcaef96237091bc8851fa1ccd34c475038f3197c9f2
|