result package
A fully type-annotated Rust-like Result type for Python.
- class Err(_error)[source]
Bases:
result._core._ResultMixin[result._core.T,result._core.E]Err result type.
A value that signifies failure and which stores arbitrary data for the error.
- Parameters
_error (~E) –
- unwrap()[source]
Returns real return type or raises an exception if unsuccessful.
- Return type
NoReturn
- class LazyResult(func, *args, **kwargs)[source]
Bases:
result._core._ResultMixin[result._core.T,result._core.E]See help(return_lazy_result).
- result()[source]
Retrieve the Result object corresponding with this LazyResult.
Calls the function corresponding with this LazyResult (this function will only be called once, even if this method is called multiple times) and returns the same Result returned by that function.
- class Ok(_value)[source]
Bases:
result._core._ResultMixin[result._core.T,result._core.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.
- Parameters
- Return type
Callable[…,LazyResult[~T, ~E]]