diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index e1578a7cc5599c7..b008f9078e49840 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -1302,22 +1302,6 @@ These are not used in annotations. They are building blocks for creating generic c = concatenate('one', b'two') # error: type variable 'A' can be either str or bytes in a function call, but not both - If a generic type is commonly generic over just one type you can use - ``default`` to specify this type:: - - T = TypeVar("T", default=int) - - class Box(Generic[T]): - def __init__(self, value: T | None = None): - self.value = value - - reveal_type(Box()) # type is Box[int] - reveal_type(Box(value="Hello World!")) # type is Box[str] - - A TypeVar without a default cannot follow a TypeVar with a default. - - .. TODO add more about this - At runtime, ``isinstance(x, T)`` will raise :exc:`TypeError`. In general, :func:`isinstance` and :func:`issubclass` should not be used with types.