Special annotation for explicitly declaring a type alias.
typing.TypeAlias
from typing import TypeAlias
Factors: TypeAlias = list[int]
from typing import Generic, TypeAlias, TypeVar
T = TypeVar("T")
"Box" does not exist yet,
so we have to use quotes for the forward reference.
Using ``TypeAlias`` tells the type checker that this is a type alias declaration,
not a variable assignment to a string.
BoxOfStrings: TypeAlias = "Box[str]"
class Box(Generic[T]):
@classmethod
def make_box_of_strings(cls) -> BoxOfStrings: ...