from typing import TypeVar, Generic T = TypeVar('T') class Box(Generic[T]): def __init__(self, x: T) -> None: self.x = x def get(self) -> T: return self.x b: Box[int] = Box(3) print(b.get() + 1)