Skip to content

Commit

Permalink
Documentation be gone!
Browse files Browse the repository at this point in the history
  • Loading branch information
Gobot1234 committed Apr 30, 2023
1 parent 2ac3116 commit 2678cc7
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 2678cc7

Please sign in to comment.