explodinglabs/jsonrpcserver

"Result" monad's "Left" and "Right" types are reversed

mikepii opened this issue · 3 comments

Result is defined as:

Result = Either[SuccessResult, ErrorResult]

However, the runtime values are reversed:

def validate_result(result: Result) -> None:
"""Validate the return value from a method.
Raises an AssertionError if the result returned from a method is invalid.
Returns: None
"""
assert (isinstance(result, Left) and isinstance(result._error, ErrorResult)) or (
isinstance(result, Right) and isinstance(result._value, SuccessResult)
), f"The method did not return a valid Result (returned {result!r})"

Therefore mypy complains if users type their methods with -> Result.

bcb commented

Are you able to send a PR for this?

bcb commented

Otherwise I can do it later today.

Thanks for reporting by the way.

sure, I'll send a PR