Checked exceptions for Python. Declare what your functions raise, and let saferaise enforce it - using your existing try/except blocks.
Project description
Checked exceptions for Python. Declare what your functions raise, and let saferaise enforce it - using your existing try/except blocks.
CAUTION: Alpha: The API may change between releases, and using this right now might very well break your code in weird ways, so don't use it in production.
Quick Start
# entrypoint.py
import saferaise
saferaise.register("app") # instrument app's try/except blocks before importing it
import app
with saferaise.enable(): # activate checking for this scope
app.main()
# app.py
from saferaise import raises
@raises(ValueError)
def parse_input(raw: str) -> int:
return int(raw)
def main():
try:
parse_input("abc") # ValueError is caught here - @raises is satisfied
except ValueError:
print("bad input")
register must be called before importing the package it instruments, and in a separate file from the code being instrumented.
Documentation
Full documentation is available at https://paillat.dev/saferaise
License
MIT License. See LICENSE for details.
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
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 saferaise-0.0.1a12.tar.gz.
File metadata
- Download URL: saferaise-0.0.1a12.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.26.6 CPython/3.13.12 Linux/6.14.0-1017-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
061ad487b74accc2bcde7c57754b8d1d5380ec5c85c4240b32c7a9739d4c6099
|
|
| MD5 |
4abadd9824c8c144c27fa77e5fff5990
|
|
| BLAKE2b-256 |
ded5ba965f8ea2e6b97d3d6d66c8245ed9dcf8d30d0766302e648147ea2f2248
|
File details
Details for the file saferaise-0.0.1a12-py3-none-any.whl.
File metadata
- Download URL: saferaise-0.0.1a12-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.26.6 CPython/3.13.12 Linux/6.14.0-1017-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
875f0cc8d4aa0e078584c9976b1f80a551378fcf41e68a37aa67035cf113dd16
|
|
| MD5 |
dc61bb974b8593beba689443b6052903
|
|
| BLAKE2b-256 |
f2b15bc620190982f822345deaebdc87e86509dd5e112462370fb2bf568462ee
|