Skip to main content

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.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for crashbytes-result 1.1.5
File Size Uploaded
crashbytes_result-1.1.5.tar.gz 40.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for crashbytes-result 1.1.5
File Interpreter ABI Platform
crashbytes_result-1.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 45.1 kB

Release files / crashbytes_result-1.1.5.tar.gz

Download URL crashbytes_result-1.1.5.tar.gz
Size 40.5 kB
Tags Source
SHA-256 checksum
How to use checksums
546b1a5507909bbf6873ddabed7debd0a7b36793a3119ef7aa5904a479eafd64
BLAKE2b-256 checksum
How to use checksums
568104afcce8e1465f8d68a7a9ee08987d3e14249ed8ff3f889157da17fe8bb4
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 1, 2026.

Transparency log

Release files / crashbytes_result-1.1.5-py3-none-any.whl

Download URL crashbytes_result-1.1.5-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ec6524a264d04175adc0ba0eddf14fc4500090932e87dc8cd06b71ad35301ce4
BLAKE2b-256 checksum
How to use checksums
35b313881aaf9b8155b8b429b286169eb73226e2601f9c876c2fa730353cd1de
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 1, 2026.

Transparency log

Release history Release notifications | RSS feed

1.1.9

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

This release

1.1.5 This release

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page