-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
What if duck types are unions of all the ducklings #11516
Comments
This feature request appears to be based on a misunderstanding of the Python type system. The type annotation |
That's obviously not what I am saying lol. This issue is regarding addressing the problems introduced by the 'ducktyping' functionality defined in pep 484, which states that |
I don't understand what you're asking for here. I'm also not sure that you understood my previous point, so let me try again. In type theory, if you have a class Are you suggesting that mypy add a new mode where it deviates from the behavior specified in PEP 484 and treats Or perhaps what you're asking is for new special forms to be added to the type system that represent "a float that is not an int" ( Or perhaps what you're saying is that when mypy prints the type Or perhaps I haven't yet captured what you're proposing. If that's the case, can you provide more specifics? |
Edit: Now I get it. I totally missed the fact the hierarchy is fake for those very specific types. Been living too long on mypy-island. I think @KotlinIsland wants
Probably subject for a typing issue... |
@ikonst yeah, exactly. I plan on implementing this in basedmypy, it will be an interesting experiment. |
@ikonst, what do you mean by "emit |
No, annotating something with |
Ah, I see what you mean. Thanks for the explanation. Yeah, that's an interesting experiment. Let us know what you find. |
If the duck typed types were actually unions of all the ducklings then it would fix a bunch of edge cases that arise.
And would make this feature more easily understood and discovered.
edge cases:
It would also be useful to have type types for
float
andbytes
, when you want exactlyfloat
and don't want any stinkingint
s.Related #11511, #11145
The text was updated successfully, but these errors were encountered: