result package
A fully type-annotated Rust-like Result type for Python.
- class Err(_error)[source]
Bases:
result.result._ResultMixin[result.result.T,result.result.E]Err result type.
A value that signifies failure and which stores arbitrary data for the error.
- Parameters
_error (~E) –
- class Ok(_value)[source]
Bases:
result.result._ResultMixin[result.result.T,result.result.E]Ok result type.
A value that indicates success and which stores arbitrary data for the return value.
- Parameters
_value (~T) –
- return_lazy_result(func)[source]
Converts the return type of a function from result to a “lazy” result.
In order to fetch the real return type from lazy_result, you must call lazy_result.result() or any other valid Result method [e.g. lazy_result.unwrap()].
This decorator is useful when dealing with functions that return Result[None, E] (i.e. functions that are used soley for their side-effects), since it makes it harder to ignore potential errors.