Callable generic type alias without parameter #1134
Answered
by
erictraut
decorator-factory
asked this question in
Q&A
-
QuestionWhen a generic callable type alias, like It seems to me that the latter should be used (to be consistent with generic classes, e.g. Codefrom collections.abc import Callable
from typing import TypeVar
T = TypeVar("T")
def f1() -> Callable[[T], T]:
...
g1 = f1()
reveal_type(g1)
reveal_type(g1(42))
Hmm = Callable[[T], T]
def f2() -> Hmm:
...
g2 = f2()
reveal_type(g2)
reveal_type(g2(42)) Pyright's (1.1.237) answer
Mypy's (0.942) answer
|
Beta Was this translation helpful? Give feedback.
Answered by
erictraut
Apr 14, 2022
Replies: 1 comment 1 reply
-
I think this is an inconsistency (i.e. a bug) in pyright. It should mirror the behavior of mypy in this case. I'll fix it. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
decorator-factory
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this is an inconsistency (i.e. a bug) in pyright. It should mirror the behavior of mypy in this case. I'll fix it.