-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Pretty-print Void differently from NoneTyp #1959
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
Comments
Added the "affects/strict-optional" label because I suspect this issue may be especially acute in the presence of |
(For the truncation of lists of types in tuples and unions, see #287.) |
This is fixed in the |
A simple fix that prints Void as |
|
We've repeatedly seen issues where mypy emits an error that looks like
type "foo" does not match type "foo"
, where the two types in question are identical as printed. That's super confusing for a user and makes mypy look quite buggy -- why is it saying this type doesn't match itself?There are two recurring causes for this kind of symptom that I can recall seeing:
We should probably stop suppressing long lists -- if the type is complicated, it's complicated, and if there's an error the user almost surely would rather see it whatever it is -- but those are at least mitigated by more or less explicitly being elliptical.
The cases with "None" vs "None" are extra confusing because there's nothing the user can see that at all points to why mypy could possibly consider these to be two different types internally. After all, they're just None! -- what internal structure does that have? The most recent instance I've run into is #1956 today.
Our messages would be more informative in these cases if we rendered
Void
andNoneTyp
differently -- so at least one of them wasn't simply the string "None". This may show a bit of puzzling complexity to the user... but it's complexity that's really there in mypy's behavior, and it's probably better for the user to be given a hope of seeing its work. (It's possible that per #1278 and #1847 the ultimate solution should be to eliminate that complexity in the behavior, at which point it'll disappear from the user's view as well and in total honesty.)For example, based on the docstring of
Void
:perhaps it could be rendered as something like
NoneRet
-- recognizably connected to "None" but gesturing at its more specific nature.The text was updated successfully, but these errors were encountered: