-
-
Notifications
You must be signed in to change notification settings - Fork 143
add Partition #1905 #1908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add Partition #1905 #1908
Conversation
|
maybe add more tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect to have a partition function that:
- Unwraps the values inside both
SuccessandFailureobjects
So, something like this:
vals = [Result.from_value(1), Result.from_failure('a')]
x: tuple[list[int], list[str]] = returns.methods.partition(vals) # type is inferred automatically, of course
assert x[0] == [1]
assert x[1] == ['a']the same for IOResult must be supported as:
vals = [IOResult.from_value(1), IOResult.from_failure('a')]
x: tuple[list[IO[int]], list[IO[str]]] = returns.methods.partition(vals) # type is inferred automatically, of course
assert x[0] == [IO(1)]
assert x[1] == [IO('a')]I guess that we can use ResultBased interface for that.
|
additional func witch do partition and unwraping? |
|
not additional, but the only one. there's no problem in writing a |
|
finally some working code |
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: sobolevn <mail@sobolevn.me>
|
can't understand why IOResult unwrapped to int instead of IO[int] |
sobolevn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ 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 ☔ View full report in Codecov by Sentry. |
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: sobolevn <mail@sobolevn.me>
sobolevn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot! Great work!
I have added partition func to result module
Checklist
CHANGELOG.mdRelated issues
🙏 Please, if you or your company finds
dry-pythonvaluable, help us sustain the project by sponsoring it transparently on https://github.com/sponsors/dry-python. As a thank you, your profile/company logo will be added to our main README which receives hundreds of unique visitors per day.