Open
Description
The following type checks (pyright, all checks enabled):
T_cov = TypeVar("T_cov", covariant=True)
StrResult = Result[T_cov, str]
ExceptionResult = Result[T_cov, Exception]
def foo() -> StrResult[int]:
return Ok(1)
def baz(x: int) -> ExceptionResult[int]:
return Ok(x)
r1 = foo()
x = r1.and_then(baz)
In particular, x
is inferred to be a x: StrResult[int] | Err[Exception]
.
The expression r1.and_then(baz)
should not type check: pyright should report that a StrResult
is not compatible with a int -> ExceptionResult
because the Err types differ.
Metadata
Metadata
Assignees
Labels
No labels
Activity