-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed as not planned
Labels
Description
For the code below:
from typing import Type, TypeVar, TYPE_CHECKING
class A:
def __init__(self, arg: int) -> None:
self._arg = arg
class B(A):
def __init__(self, arg: int) -> None:
super().__init__(arg)
_TA = TypeVar('_TA', bound=A)
def get_entity(entity_class: Type[_TA], arg: int) -> _TA:
if TYPE_CHECKING:
reveal_type(entity_class) # <- Revealed type is 'Type[_TA`-1]'
reveal_type(entity_class(1)) # <- Revealed type is '_TA`-1'
return entity_class(arg)
if __name__ == '__main__':
print(get_entity(B, 3))mypy 0.641 produces garbled output at lines 19 and 20:
H:\My Documents\PyCharm\tst>mypy --strict tst84.py
tst84.py:19: error: Revealed type is 'Type[_TA`-1]'
tst84.py:20: error: Revealed type is '_TA`-1'
Expected output is:
tst84.py:19: error: Revealed type is 'Type[_TA]'
tst84.py:20: error: Revealed type is '_TA'