Conversation
sobolevn
left a comment
There was a problem hiding this comment.
I am not sure about this feature :)
As I told you in the chat.
But, anyway - thanks a lot for working on it!
Do you see any alternatives?
| function: Callable[ | ||
| [_ValueType], | ||
| Kind2['Result', _NewValueType, _ErrorType], | ||
| Kind2['Result', _NewValueType, _ErrorType | _NewErrorType], |
There was a problem hiding this comment.
The problem with this approach is that it works with Exception subtypes, but it does not work if you have Result[int, int] and Result[int, str]
How would you compose these two objects? Result[int, int | str] might not make any sense.
There was a problem hiding this comment.
How would you compose these two objects?
Result[int, int | str]might not make any sense.
Thank you for the review! I see your point, but isn’t int | str better than dealing with Any? At least with int | str, we can use pattern matching to handle each case explicitly.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1975 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 80 81 +1
Lines 2485 2601 +116
Branches 437 44 -393
==========================================
+ Hits 2485 2601 +116 ☔ View full report in Codecov by Sentry. |
sobolevn
left a comment
There was a problem hiding this comment.
Ok, I tested this out. Right now I kinda agree that this makes a lot of inference better.
But, in case we are adopting it - we need to make sure that all ResultLike behave the same way. Can you please address this?
…sult, RequiresContextIOResult, RequiresContextResult
|
@sobolevn Added similar behavior for |
|
The CI is failing, please take a look. |
|
There was a linting issue, it should be fine now. |
sobolevn
left a comment
There was a problem hiding this comment.
Please, don't forget about interfaces.
I have made things!
Checklist
CHANGELOG.mdRelated issues
This pull request fixes the issue of error types not composing in chains by using Union, improving clarity and type safety. However,
Anycan still appear in some cases. SettingSuccessandFailureto use_NothingorNoReturninstead ofAnyhelps with type inference but breaks many existing tests. I’m not an expert in type theory, but personally, I’d find it very useful to see fully composed error types withoutAny