Skip to content

Commit

Permalink
idk what wrong with Nothing type
Browse files Browse the repository at this point in the history
  • Loading branch information
romanmatveevsky committed Aug 13, 2024
1 parent 7b37a0f commit dd94a17
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
13 changes: 7 additions & 6 deletions docs/pages/result.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,14 @@ partition

:func:`partition <returns.result.partition>` is used to convert
list of ``Result`` instances to a tuple of two lists: successes and failures.
.. code:: python

>>> from returns.result import Failure, Success
>>> from returns.methods import partition
>>> results = [Success(1), Failure(2), Success(3), Failure(4)]
>>> partition(results)
([1, 3], [2, 4])
.. code:: python
>>> from returns.result import Failure, Success
>>> from returns.methods import partition
>>> results = [Success(1), Failure(2), Success(3), Failure(4)]
>>> partition(results)
([1, 3], [2, 4])
FAQ
---
Expand Down
5 changes: 5 additions & 0 deletions tests/test_result/test_result_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest

from returns.io import IO, IOResult
from returns.maybe import Nothing, Some
from returns.methods import partition
from returns.result import Failure, Success

Expand All @@ -19,6 +20,10 @@
),
([IO(1), IO(2)], [IO(None)]),
),
(
(Some(1), Some(2), Nothing),
([1, 2], []),
),
])
def test_partition(containers, expected):
"""Test partition function."""
Expand Down
11 changes: 11 additions & 0 deletions typesafety/test_methods/test_partition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,14 @@
x: Tuple[IOResult[int, str], IOResult[int, str]]
reveal_type(partition(x)) # N: Revealed type is "Tuple[builtins.list[returns.io.IO[builtins.int]], builtins.list[returns.io.IO[builtins.str]]]"
- case: partition_maybe
disable_cache: false
main: |
from typing import List, Tuple, Never
from returns.maybe import Maybe, Some, Nothing, Maybe, _Nothing
from returns.methods import partition
x: Tuple[Some[int], Some[int], Maybe[None]]
reveal_type(partition(x)) # N: Revealed type is "Tuple[builtins.list[builtins.int], builtins.list[None]]"

0 comments on commit dd94a17

Please sign in to comment.