Skip to main content

Checked exceptions for Python. Declare what your functions raise, and let saferaise enforce it - using your existing try/except blocks.

Project description

Alpha PyPI py.typed CI License: MIT

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.github.io/saferaise

License

MIT License. See LICENSE for details.

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

saferaise-0.0.1a8.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

saferaise-0.0.1a8-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file saferaise-0.0.1a8.tar.gz.

File metadata

  • Download URL: saferaise-0.0.1a8.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for saferaise-0.0.1a8.tar.gz
Algorithm Hash digest
SHA256 9e2d75d8b5e14f648f71f9f89617b184fd2c3f93235bb01cc2962dfe00ee2b1b
MD5 f2e77d54aa84d008e443017965ff8ea0
BLAKE2b-256 1c12b16910ca1f820dd3277f83afdb130c3d69951e774e93a66795e46a341fc8

See more details on using hashes here.

File details

Details for the file saferaise-0.0.1a8-py3-none-any.whl.

File metadata

  • Download URL: saferaise-0.0.1a8-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for saferaise-0.0.1a8-py3-none-any.whl
Algorithm Hash digest
SHA256 5a173bbe7b6b61c70d91b692e483fd34b20f5000381ad92a4f8012a4ec10e36e
MD5 6bcecefad54d9c9f08f9efcea9fa27e5
BLAKE2b-256 deab02932ef66674e12d9927997d880531f72a6b02e0a2bd3c2b944758e23abe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page