-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Dict constructor: Generator has incompatible item type "object"; expected "Tuple[Any, Any]" #5287
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
In the second case (with a The rest is a duplicate of #4975 |
But it seems like you could infer the two-tuple from the presence of the two-tuple in that join. For that matter, it seems just as easy (easier) to infer the exact number of elements from the second argument to |
No, this would be too unsafe.
This is for variable definitions, what you need is |
Indeed, this worked for me. Thanks for the help, and sorry for the unnecessary bug report. |
I filed an issue about improving the
dict
constructor signature ontypeshed
, but I think there's also a related bug in the way MyPy is generating this error.I have the following code:
On the second line of this, I get the following error:
I get that the error is due to my above-reported problem with the
dict
constructor signature; however, I also don't believe the error is right. First, theobject
is too generic. But second, if I improve it slightly (improved for type-checking purposes; the code isn't actually any better/worse):This yields the exact same error, and it shouldn't. I now have a generator of tuples, and it should recognize that. There should be no error with this second approach.
The text was updated successfully, but these errors were encountered: