Skip to content

Commit

Permalink
Rename is in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed Feb 3, 2019
1 parent 6e8f531 commit 49653ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
11 changes: 8 additions & 3 deletions returns/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
from returns.result import Failure, Success


def is_successful(monad):
"""Determins if a monad was a success or not."""
def is_successful(container):
"""
Determins if a container was successful or not.
We treat container that raise ``UnwrapFailedError`` on ``.unwrap()``
not successful.
"""
try:
monad.unwrap()
container.unwrap()
except UnwrapFailedError:
return False
else:
Expand Down
8 changes: 4 additions & 4 deletions returns/functions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ from returns.result import Result

_ContainerType = TypeVar('_ContainerType', bound=Container)
_ReturnType = TypeVar('_ReturnType')
_ReturnsMonadType = TypeVar(
'_ReturnsMonadType',
_ReturnsContainerType = TypeVar(
'_ReturnsContainerType',
bound=Callable[..., Container],
)


def is_successful(monad: _ContainerType) -> bool:
def is_successful(container: _ContainerType) -> bool:
...


# Typing decorators is not an easy task, see:
# https://github.com/python/mypy/issues/3157

def pipeline(function: _ReturnsMonadType) -> _ReturnsMonadType:
def pipeline(function: _ReturnsContainerType) -> _ReturnsContainerType:
...


Expand Down

0 comments on commit 49653ab

Please sign in to comment.