-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
No overload variant of "fromkeys" of "dict" matches argument types [typing.Iterable[Any], Union[Any, def (*Any, **Any) -> Any]] #2254
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
Thanks for the question! I'd be happy to help but I'm not sure I understand the context of that definition. Can you show a complete, small, self-contained program that exhibits this behavior? |
Hello, thanks for the reply. Here is what I have done.
Code is working fine (Python 3.5), but when I run mypy, I have the following error :
I am not sure if it is a problem, or if I have done something wrong. |
Oh, it seems you've hit two issues! When I run that example I get:
(Line 6 is the The first complaint is because in typeshed, The second complaint is probably because mypy doesn't understand My recommendation is to add a |
This came up in python/mypy#2254. I don't know why it was previously defined as a staticmethod, perhaps there was an old mypy issue?
Isn't the second error just because you passed an |
This came up in python/mypy#2254. I don't know why it was previously defined as a staticmethod, perhaps there was an old mypy issue?
Oh, good catch! I will fix that at the same time. Wait for the next iteration of python/typeshed#604. |
(This, too, came up in python/mypy#2254 -- thanks @rwbarton!)
OK then I think I have fixed both issues and this can be closed. @trnsnt, to get the fix right away you'll have to pull down the mypy repo, git submodule update, and then in the typeshed subdir do something like "git co master; git pull". |
Sadly making fromkeys() a classmethod breaks, due to #328, so this is not fixed. Really sorry!! I went too fast here. |
(And this is not a duplicate of that issue -- there's the separate problem that Reid pointed out about the real fromkeys() taking an Iterable.) |
Keeping this open until #328 is fixed and typeshed has been updated. |
Seems like this is fixed. This variation of the OP's post:
produces no errors on current mypy |
Hello,
I have defined a dict wrapper where I override fromkeys method.
I have this method signature
and this give me the following error : No overload variant of "fromkeys" of "dict" matches argument types [typing.Iterable[Any], Union[Any, def (_Any, *_Any) -> Any]]
Thanks !
The text was updated successfully, but these errors were encountered: