Guest User

Untitled

a guest
Dec 9th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. from typing import Union, Generic, TypeVar
  2.  
  3.  
  4. T = TypeVar("T")
  5.  
  6.  
  7. class Expected(Generic[T]):
  8. def __init__(self, value_or_error: Union[T, Exception]):
  9. self._value_or_error = value_or_error
  10.  
  11. def is_valid(self) -> bool:
  12. return not isinstance(self._value_or_error, Exception)
Add Comment
Please, Sign In to add comment