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.1.8.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.1.8.tar.gz.
File metadata
- Download URL: can_raise-0.1.8.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 |
cb454f0056080b3867af92694fa6de9884da51307d12ca35ec81c9de49d9bd27
|
|
| MD5 |
9d0d64645a8616a40107ac8177648f5c
|
|
| BLAKE2b-256 |
bbca739bd1f116adf0d063562cbb89cb57da2e07991e2ad840de3f76814cb0e7
|
File details
Details for the file can_raise-0.1.8-py3-none-any.whl.
File metadata
- Download URL: can_raise-0.1.8-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 |
94a58f91fc5781a331ece1f7f743913c032d6eff2043e8a30507c8d0bcf3adf7
|
|
| MD5 |
156031c8f23c6609a2c0b2802b9d41b1
|
|
| BLAKE2b-256 |
a888a1cdf40ea0d365214ab3cedc8de147d615d6ecbb9cdc0ba692d4bac920a3
|