That's not flying, it's falling with style: Exceptions with extras
Long ago, I found myself writing the same boilerplate for condition checks and exception wrappers over and over. So I
gathered some helpers together to cut down on repetitive error-handling code. When I switched projects later, I wanted
those helpers there, too! That's how py-buzz came to be.
Now, I have a collection of really useful exception helpers that I can use in all my projects, and I'm sharing them with you!
Getting started
Python 3.11 or newer is required, and installation takes one line:
uv add py-buzz
Here's a small example with a project-specific exception:
from buzz import Buzz
class ConfigError(Buzz):
pass
def read_port(value: object) -> int:
port = ConfigError.ensure_type(value, int, "Port must be an integer")
ConfigError.require_condition(1 <= port <= 65535, "Port must be between 1 and 65535")
return port
def parse_port(value: str) -> int:
with ConfigError.handle_errors("Couldn't parse the configured port"):
port = int(value)
return read_port(port)
Here, ensure_type() checks the value at runtime and returns it with a narrowed type, while require_condition()
raises ConfigError if the port is out of range. handle_errors() gives parsing failures
a bit more context by wrapping the original ValueError in a ConfigError.
What's in the box
- Checks for conditions, defined values, types, and
Literalvalues, with useful errors. - More context around handled exceptions, or a new exception raised from the original.
- Several failed checks gathered into one report.
- Synchronous and asynchronous retries with exponential backoff through
Buzz.retry()andBuzz.retry_async(). - A
Buzzbase class for project-specific exceptions, along with standalone helpers for existing exception types.
Further reading
The documentation has feature guides and the API reference.
A set of demos is also included if you want to see the features in action. You can run them with one line:
uvx --from='py-buzz[demo]' py-buzz-demo
Metadata
Release files for py-buzz 9.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| py_buzz-9.0.1.tar.gz | 23.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_buzz-9.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 54.7 kB
Release files / py_buzz-9.0.1.tar.gz
| Download URL | py_buzz-9.0.1.tar.gz |
|---|---|
| Size | 23.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
972c062b23a2369397c3172ab3f87a6429888ff2fdf280ec4c637f5420c20a54
|
|
BLAKE2b-256 checksum How to use checksums |
da10e18d4b02d049484460dd1d1aa9a1a84761e49f9d4f85ae1d1b03d3fd77bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","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}
|
Release files / py_buzz-9.0.1-py3-none-any.whl
| Download URL | py_buzz-9.0.1-py3-none-any.whl |
|---|---|
| Size | 31.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5b4f5bef281a5f8ce4ab788099ce59042e2cd94864d5ecc8a5508fec366277c1
|
|
BLAKE2b-256 checksum How to use checksums |
174b5120a5954cb13a9c624b0f4bdc50c0f8f95e49e7997ee6f829a6fc8c0970
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","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}
|
Security for py-buzz 9.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.