Type hints in Python.

Generics

from typing import TypeVar

T = TypeVar("T")

def generic_adder(a: T, b: T) -> T:
    return a + b
from typing import TypeVar, Generic, List
from dataclasses import dataclass

T = TypeVar("T")

@dataclass
class Vertex(Generic[T]):
    children: List[Vertex]
    value: T

Bibliography