Skip to content

Overloaded classmethods don't work #328

Closed

Description

@JukkaL

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.

Activity

  1. dmoisset commented on Jun 16, 2016

    @dmoisset
    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?

  2. added this to the milestone on Oct 15, 2016
  3. added a commit that references this issue on Oct 15, 2016
  4. removed this from the milestone on Mar 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions