skillfed

result

A Rust-like result type for Python

result v0.17.0 2.5M downloads/30d#3,024 on PyPI1,680
Permissive license MIT Abandoned released

What it is and what it does

Result is a type-safe container for representing success or failure outcomes without relying on exceptions. It provides Ok and Err classes that wrap values, letting you encode success or error states directly in function return types. The package is inspired by Rust's Result enum and fully type-annotated, making it compatible with MyPy and other type checkers for compile-time safety.

You use it by returning Ok(value) for success or Err(error) for failure, then checking the result with isinstance, is_ok/is_err functions, or Python 3.10+ match statements. It includes utility methods like map, unwrap, expect, and unwrap_or to transform and extract values. The design encourages explicit error handling at call sites rather than implicit exception propagation, making error paths visible in code.

Use it for:

  • Building APIs or functions where error cases are part of the normal control flow and should be handled explicitly rather than caught.
  • Type-checking error handling with MyPy by narrowing result types through isinstance checks to ensure all branches are covered.
  • Replacing tuple-based error returns (like returning (value, error_msg)) with a clearer, type-safe Result[T, E] signature.
  • Chaining operations on results using map and map_err to transform values or errors without nested conditionals.
  • Porting Rust code to Python while preserving the Result pattern for consistency and familiar error semantics.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a Rust-inspired Result type for Python that represents either a success value (Ok) or an error (Err), enabling explicit error handling without exceptions.

Yes, if you prefer explicit error handling and type safety over exceptions. The package is stable, has low install friction, and is widely used (top 5000 PyPI). However, note that the repository is archived and abandoned—while the code is mature and unlikely to need updates, you will not receive maintenance or security patches. Use it for new projects only if your team is comfortable with that trade-off.

Install

result on PyPI

pip

pip install result

uv

uv add result

poetry

poetry add result

Installing result

Before you install

Low install friction with a single lightweight dependency (typing-extensions). Repository is archived and maintenance is abandoned as of 803 days since last release, though the package remains stable and widely used.

License in practice

MIT license permits unrestricted use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.

Quickstart

pip install result

from result import Ok, Err, Result

def divide(a: int, b: int) -> Result[int, str]:
    if b == 0:
        return Err("Cannot divide by zero")
    return Ok(a // b)

result = divide(10, 2)
if isinstance(result, Ok):
    print(result.ok_value)  # 5
else:
    print(result.err_value)

Verify before relying

  • Whether the archived repository status affects long-term security patch availability or community support for edge cases.
  • Performance characteristics when used in high-throughput or latency-sensitive code paths compared to exception-based patterns.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 1 — typing-extensions
Maintenance abandoned — 803 days since the last release
Last repo commit (repository archived)
First released
Downloads 2,520,319/month — #3,024 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: result-0.17.0-py3-none-any.whl

Keywords: rust, result, enum

Development Status :: 4 - BetaLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

rust result type pythonok err error handlingexplicit error return valuesresult enum pythontype-safe error handlingfunctional error handlingok err pattern
error-handlingtype-safetyrust-inspired

More Software Development packages