Skip to content
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

Overloaded classmethods don't work #328

Closed
JukkaL opened this issue Jul 25, 2014 · 1 comment
Closed

Overloaded classmethods don't work #328

JukkaL opened this issue Jul 25, 2014 · 1 comment
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-1-normal topic-overloads

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Jul 25, 2014

Overloaded classmethods don't work correctly in the type checker:

from typing import overload
class A:
    @overload
    @classmethod
    def f(cls, x: int) -> None: pass
    @overload
    @classmethod
    def f(cls, x: str) -> None: pass
A.f(1)  # No overload variant matches argument types
A.f('')  # No overload variant matches argument types

This affects dict.fromkeys.

@JukkaL JukkaL added the bug label Jul 25, 2014
@dmoisset
Copy link
Contributor

Currently the typeshed declares fromkeys as a staticmethod, and I still get the same problem:

d = {"greeting": "hello", "name": "Bob"}
print(dict.fromkeys(d, 42))  # No overload variant matches argument types

is this the same bug?

@gvanrossum gvanrossum added this to the 0.5 milestone Oct 15, 2016
gvanrossum pushed a commit to python/typeshed that referenced this issue Oct 15, 2016
Reason: python/mypy#328

* Revert "Make fromkeys() take an Iterable instead of a sequence. (#605)"

  This reverts commit 66e8d4a.

* Revert "Make dict.fromkeys() a classmethod (which it is). (#604)"

  This reverts commit 26dfcb6.

* Add an explanation for fromkeys() being a staticmethod.
@gvanrossum gvanrossum removed this from the 0.5 milestone Mar 29, 2017
@JukkaL JukkaL added the false-positive mypy gave an error on correct code label May 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-1-normal topic-overloads
Projects
None yet
Development

No branches or pull requests

4 participants