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

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.7
File Size Uploaded
crashbytes_result-1.1.7.tar.gz 50.6 kB Details

Built distribution (wheel)

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

Total release size: 55.1 kB

Release files / crashbytes_result-1.1.7.tar.gz

Download URL crashbytes_result-1.1.7.tar.gz
Size 50.6 kB
Tags Source
SHA-256 checksum
How to use checksums
977bccc608a18b0cfe849eeab29ecd822e3c24f3cf820fe9f451acaf498c9403
BLAKE2b-256 checksum
How to use checksums
212492c17a22cf6e2e936f895289fe8a7330da825559939130e90c900444b878
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 Sep 1, 2026.

Transparency log

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

Download URL crashbytes_result-1.1.7-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
56796d13f843818d053b7e74f79424837b858c3a9d364a22470095e8490b99d0
BLAKE2b-256 checksum
How to use checksums
22ec6e9589d528330dd960d55c4ff2912fa3ea3203819a58610be34935844e31
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 Sep 1, 2026.

Transparency log

Release history Release notifications | RSS feed

1.1.9

2 release files

1.1.8

2 release files

This release

1.1.7 This release

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