File tree Expand file tree Collapse file tree 1 file changed +0
-16
lines changed Expand file tree Collapse file tree 1 file changed +0
-16
lines changed Original file line number Diff line number Diff line change @@ -1302,22 +1302,6 @@ These are not used in annotations. They are building blocks for creating generic
13021302
13031303 c = concatenate('one', b'two') # error: type variable 'A' can be either str or bytes in a function call, but not both
13041304
1305- If a generic type is commonly generic over just one type you can use
1306- ``default `` to specify this type::
1307-
1308- T = TypeVar("T", default=int)
1309-
1310- class Box(Generic[T]):
1311- def __init__(self, value: T | None = None):
1312- self.value = value
1313-
1314- reveal_type(Box()) # type is Box[int]
1315- reveal_type(Box(value="Hello World!")) # type is Box[str]
1316-
1317- A TypeVar without a default cannot follow a TypeVar with a default.
1318-
1319- .. TODO add more about this
1320-
13211305 At runtime, ``isinstance(x, T) `` will raise :exc: `TypeError `. In general,
13221306 :func: `isinstance ` and :func: `issubclass ` should not be used with types.
13231307
You can’t perform that action at this time.
0 commit comments