Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Type[C] is not considered callable #1846

Closed
@gvanrossum

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.

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