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

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.9
File Size Uploaded
crashbytes_result-1.1.9.tar.gz 50.5 kB Details

Built distribution (wheel)

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

Total release size: 55.1 kB

Release files / crashbytes_result-1.1.9.tar.gz

Download URL crashbytes_result-1.1.9.tar.gz
Size 50.5 kB
Tags Source
SHA-256 checksum
How to use checksums
02a28188fb654d56849554477595e00372b38ea242a3d52ac38cd49edec2aab8
BLAKE2b-256 checksum
How to use checksums
b7159487a38868cd7b2e168c8318ac787ac54e8c85494cdcba2a3cdce070145f
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 Oct 1, 2026.

Transparency log

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

Download URL crashbytes_result-1.1.9-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
351aa3001fb910c2b8df6049c2d8e400de79da404c994aa37493d00b28bb991d
BLAKE2b-256 checksum
How to use checksums
acc217ad0a8657419a86173c35ba8a4ac9143c94742228939c3546d9f80bc2ec
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 Oct 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.9 This release

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

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