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.1a7.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.1a7-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: saferaise-0.0.1a7.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.1a7.tar.gz
Algorithm Hash digest
SHA256 eca0484d8e79601366b429078342d6303d24eb1b0107dc22039f8eed3fc597ec
MD5 541a73cb533bcd8323548d99ed693b8c
BLAKE2b-256 3b8f6b1096d2c31e69d625883a9220f9bb06d86a158a4587ef5ed9e2bc5b52c3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: saferaise-0.0.1a7-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.1a7-py3-none-any.whl
Algorithm Hash digest
SHA256 57b349a4915f706d2540d2844432427a612611d9dc2c8984b47940e63672e679
MD5 ca653e6e4bd10dc5f0f5a38ea5f7f1d0
BLAKE2b-256 95e4777c76050e141b441e522201a866a1dd65ab4da98d5651dafbede54b46a8

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