dry-python / returns

Make your functions return something meaningful, typed, and safe!
https://returns.rtfd.io
BSD 2-Clause "Simplified" License
3.48k stars 115 forks source link

add Partition #1905 #1908

Closed RomanMIzulin closed 1 month ago

RomanMIzulin commented 1 month ago

I have added partition func to result module

Checklist

Related issues

RomanMIzulin commented 1 month ago

maybe add more tests

RomanMIzulin commented 1 month ago

additional func witch do partition and unwraping?

sobolevn commented 1 month ago

not additional, but the only one. there's no problem in writing a for loop to partinion based on is_succesful

RomanMIzulin commented 1 month ago

finally some working code

RomanMIzulin commented 1 month ago

can't understand why IOResult unwrapped to int instead of IO[int]

E   pytest_mypy_plugins.utils.TypecheckAssertionError: Invalid output:
E   Actual:
E     main:7: note: Revealed type is "Tuple[builtins.list[builtins.int], builtins.list[Any]]" (diff)
E   Expected:
E     main:7: note: Revealed type is "Tuple[builtins.list[IO[builtin.int]], builtins.list[IO[builtin.int]]" (diff)
E   Alignment of first line difference:
E     E: ... "Tuple[builtins.list[IO[builtin.int]], builtins.list[IO[builtin.int]...
E     A: ... "Tuple[builtins.list[builtins.int], builtins.list[Any]]"...
RomanMIzulin commented 1 month ago

Because we used an incorrect interface 🤦 Sorry!

We need this one: https://github.com/dry-python/returns/blob/master/returns/interfaces/specific/result.py#L71

used that, seems like working, got from unwrap_or_failure func
https://github.com/RomanMIzulin/returns/blob/7b37a0fd171bc6b4e8fb62daf97736cddc002617/returns/interfaces/unwrappable.py#L10

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (82ef3ef) to head (edf92e1). Report is 127 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1908 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 80 81 +1 Lines 2485 2540 +55 Branches 437 447 +10 ========================================= + Hits 2485 2540 +55 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.