Skip to content

Commit 06b9a7a

Browse files
committed
Closes #114
1 parent a2e72eb commit 06b9a7a

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

returns/converters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ def join(container: IO[IO[_ValueType]]) -> IO[_ValueType]:
3232
"""Case for ``IO`` container."""
3333

3434

35-
@overload # noqa: WPS440
35+
@overload
3636
def join(container: Maybe[Maybe[_ValueType]]) -> Maybe[_ValueType]:
3737
"""Case for ``Maybe`` container."""
3838

3939

40-
@overload # noqa: WPS440
40+
@overload
4141
def join(
4242
container: Result[Result[_ValueType, _ErrorType], _ErrorType],
4343
) -> Result[_ValueType, _ErrorType]:
4444
"""Case for ``Result`` container."""
4545

4646

47-
def join(container): # noqa: WPS440
47+
def join(container):
4848
"""Joins two nested containers together."""
4949
return container._inner_value # noqa: WPS437

returns/primitives/container.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ def __eq__(self, other) -> bool:
4848
return False
4949
return self._inner_value == other._inner_value # noqa: WPS437
5050

51+
def __hash__(self) -> int:
52+
"""Used to use this value as a key."""
53+
return hash(self._inner_value)
54+
5155

5256
@runtime
5357
class Bindable(Protocol[_ValueType]):

tests/test_maybe/test_maybe_equality.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ def test_protocols(container, protocol):
3232
def test_equality():
3333
"""Ensures that containers can be compared."""
3434
assert Nothing is Nothing # noqa: WPS312
35-
assert Nothing == _Nothing() == _Nothing(None)
35+
assert Nothing == _Nothing() == _Nothing(None) == Some(None)
3636
assert Some(5) == Some(5)
37-
assert Some(None) == Nothing
37+
assert hash(Some(1))
38+
assert hash(Nothing)
3839

3940

4041
def test_nonequality():

tests/test_result/test_result_equality.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def test_nonequality():
3838
assert Failure(input_value) != input_value
3939
assert Success(input_value) != input_value
4040
assert Failure(input_value) != Success(input_value)
41+
assert hash(Failure(1))
42+
assert hash(Success(1))
4143

4244

4345
def test_is_compare():

0 commit comments

Comments
 (0)