Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
romanmatveevsky committed Aug 12, 2024
1 parent f1839c3 commit afe493f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 6 additions & 3 deletions returns/methods/partition.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

from typing import Iterable, List, TypeVar
from typing import Iterable, List, TypeVar, Union

from returns.interfaces.specific import result
from returns.interfaces.specific import ioresult, result
from returns.primitives.exceptions import UnwrapFailedError

_ValueType = TypeVar('_ValueType', covariant=True)
Expand All @@ -11,7 +11,10 @@

def partition(
containers: Iterable[
result.ResultBasedN[_ValueType, _ErrorType, _AdditionalType]
Union[
result.ResultBasedN[_ValueType, _ErrorType, _AdditionalType],
ioresult.IOResultBasedN[_ValueType, _ErrorType, _AdditionalType],
]
],
) -> tuple[List[_ValueType], List[_ErrorType]]:
"""
Expand Down
7 changes: 4 additions & 3 deletions typesafety/test_methods/test_partition.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
- case: partition_no_params
disable_cache: false
main: |
from returns.result import Success, Failure
from typing import List
from returns.result import Success, Failure, Result
from returns.methods import partition
x: List[Result[int, str]]
reveal_type(partition(x)) # N: Revealed type is "Tuple[builtins.list[builtin.int], builtins.list[builtin.str]]"
reveal_type(partition(x)) # N: Revealed type is "Tuple[builtins.list[builtins.int], builtins.list[builtins.str]]"
- case: partition_io_results
disable_cache: false
main: |
from typing import Tuple
from returns.result import Success, Failure
from returns.methods import partition
from returns.io import IO, IOResult
from returns.io import IO, IOResult, IOSuccess
x: Tuple[IOResult[int, str], IOResult[int, str]]
reveal_type(partition(x)) # N: Revealed type is "Tuple[builtins.list[IO[builtin.int]], builtins.list[IO[builtin.int]]"
Expand Down

0 comments on commit afe493f

Please sign in to comment.