Skip to content

Type[C] is not considered callable #1846

Closed

Description

@gvanrossum

This simple example fails:

from typing import Type, Any, Callable
def f(func: Callable[[], Any]) -> Any: return func()
class C: pass
f(C)  # This is okay
x = C()
f(type(x))  # E: Argument 1 to "f" has incompatible type Type[C]; expected Callable[[], Any]
X = C  # type: Type[C]
f(X)  # E: Argument 1 to "f" has incompatible type Type[C]; expected Callable[[], Any

This is actually present in the mypy test suite (test/test_random.py:49, the second argument to assertRaises()), so I'm treating this as a blocker.

Activity

  1. added this to the milestone on Jul 12, 2016
  2. gvanrossum commented on Jul 12, 2016

    @gvanrossum
    MemberAuthor

    I can't figure out how to solve this quickly, so I'm going to use the # type: ignore for the one place in the mypy test suite where this causes a problem ( in test-data/stdlib-samples/3.2/test/test_random.py).

  3. added a commit that references this issue on Jul 13, 2016
  4. JukkaL commented on Jul 13, 2016

    @JukkaL
    Collaborator

    #1670 is related.

  5. gvanrossum commented on Jul 13, 2016

    @gvanrossum
    MemberAuthor

    Closing as duplicate of #1670 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions