example-code-2e/08-def-type-hints/typevar_bounded.py
2021-08-07 00:44:01 -03:00

12 lines
179 B
Python

from typing import TypeVar, TYPE_CHECKING
BT = TypeVar('BT', bound=float)
def triple2(a: BT) -> BT:
return a * 3
res2 = triple2(2)
if TYPE_CHECKING:
reveal_type(res2)