-
Notifications
You must be signed in to change notification settings - Fork 83
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
Change design for improved type safety #17
Comments
That sounds interesting 🙂 |
@Emerentius @dbrgn Are you both still interested in continuing with #18? That MR is extremely useful to us and if need be I can put in some work to get that MR up-to-date. |
I'm definitely interested, I'm just a bit tight on free time to review. Getting the PR up to date and doing a review (ideally with a migration / upgrade guide for affected users) would definitely help. If it looks good, it could become the 0.6 release. CC @francium |
Alright, I updated everything here. The good news is that all tests (That are still relevant) pass. The bad news is as follows:
This apparently is a bug in MyPy. However seeing as the issue is from 2013, this won't be fixed soon. There are workarounds but those are all manual fixes. The question for you is if you are fine with this issue, because it's quite a breaking (and unwelcome) change in the use of the different I'll write a migration guide and submit the PR once we've discussed above. |
Okay I figured out the problem. The typetest was still using |
@Jasonoro that's great! |
I'm proposing that the
Result
class should be split into two classesclass Ok(Generic[T])
andclass Err(Generic[E])
and thatResult
be only a type alias forUnion[Ok[T], Err[T]]
This has the advantage that you can use
isinstance
as a replacement for matching and gain improved type checkability.For example, take this code
There is an unnecessary ambiguity in the type of
value
. You can useunwrap
, but if you have a bug in your code, it's now a runtime error and a type checker can't help you find it.On the other hand, with unions you can do this:
I can make a PR showing what this would look like.
The text was updated successfully, but these errors were encountered: