crashbytes-result
A practical Result type for Python — Ok, Err, and pattern matching.
Install
pip install crashbytes-result
Usage
from crashbytes_result import Ok, Err, Result, safe
def divide(a: float, b: float) -> Result[float, str]:
if b == 0:
return Err("division by zero")
return Ok(a / b)
result = divide(10, 3)
match result:
case Ok(value):
print(f"Result: {value}")
case Err(error):
print(f"Error: {error}")
# Or use .match()
msg = result.match(
ok=lambda v: f"Got {v:.2f}",
err=lambda e: f"Failed: {e}",
)
# @safe decorator
@safe
def parse_int(s: str) -> int:
return int(s)
parse_int("42") # Ok(42)
parse_int("abc") # Err(ValueError(...))
API
| Method | Ok | Err |
|---|---|---|
.unwrap() |
Returns value | Raises UnwrapError |
.unwrap_or(default) |
Returns value | Returns default |
.unwrap_err() |
Raises UnwrapError |
Returns error |
.map(fn) |
Ok(fn(value)) |
self |
.map_err(fn) |
self |
Err(fn(error)) |
.bind(fn) |
fn(value) |
self |
.match(ok, err) |
ok(value) |
err(error) |
.is_ok |
True |
False |
.is_err |
False |
True |
License
MIT
Metadata
Release files for crashbytes-result 1.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| crashbytes_result-1.1.6.tar.gz | 50.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| crashbytes_result-1.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 55.1 kB
Release files / crashbytes_result-1.1.6.tar.gz
| Download URL | crashbytes_result-1.1.6.tar.gz |
|---|---|
| Size | 50.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1151a009ab4f33380921d7d6e887b7ddd5b2d1bd29298c077cc81c2ae3c0046a
|
|
BLAKE2b-256 checksum How to use checksums |
1c59072c6f878bb3fca5e1c5fd4b2200124fc2607c5ef54d46e99e322e063523
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.
Transparency logRelease files / crashbytes_result-1.1.6-py3-none-any.whl
| Download URL | crashbytes_result-1.1.6-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3e0acd6d6e4603d7bc17d19970c0b9dd90a9d02ad0a07ee95ed7c3adbdde0a62
|
|
BLAKE2b-256 checksum How to use checksums |
20aa04a9d018765863e256eb5702a1acfb5367b28a5040d0679bba77aff6f336
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.
Transparency log