Skip to content

Type[C] is not considered callable #1846

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

Closed
gvanrossum opened this issue Jul 12, 2016 · 3 comments
Closed

Type[C] is not considered callable #1846

gvanrossum opened this issue Jul 12, 2016 · 3 comments

Comments

@gvanrossum
Copy link
Member

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.

@gvanrossum gvanrossum added this to the 0.4.x milestone Jul 12, 2016
@gvanrossum
Copy link
Member Author

gvanrossum commented Jul 12, 2016

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).

ddfisher pushed a commit that referenced this issue Jul 13, 2016
* SplitNamespace should derive from Namespace.

* Add band-aid type-ignore to make tests pass. See #1846.

* Sync typeshed.
@JukkaL
Copy link
Collaborator

JukkaL commented Jul 13, 2016

#1670 is related.

@gvanrossum
Copy link
Member Author

Closing as duplicate of #1670 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants