-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
Description
Assuming the following code snippet:
from typing import Callable, TypeVar, Generic
T = TypeVar('T', str, int)
Printer = Callable[[T], None]
class Klass(Generic[T]):
def __init__(self, msg: str, p: Printer[T]) -> None:
self.msg = msg
self.p = p
def echo(self) -> None:
print(self.msg)mypy returns error for print(self.msg): error: Cannot determine type of 'msg'
reveal_type fails to determine type of self.msg:
reveal_type(self.msg) results in
error: Cannot determine type of 'msg'
Revealed type is 'Any'
If we changed type variable to unconstrained, T = TypeVar('T'), everything works as expected.