Skip to content

Commit 7861a9e

Browse files
1 parent 53ca774 commit 7861a9e

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

Doc/library/typing.rst

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,27 +1368,27 @@ These are not used in annotations. They are building blocks for creating generic
13681368

13691369
.. data:: Unpack
13701370

1371-
A typing operator that conceptually marks an object as having been
1372-
unpacked. For example, using the unpack operator ``*`` on a
1373-
:class:`type variable tuple <TypeVarTuple>` is equivalent to using ``Unpack``
1374-
to mark the type variable tuple as having been unpacked::
1375-
1376-
Ts = TypeVarTuple('Ts')
1377-
tup: tuple[*Ts]
1378-
# Effectively does:
1379-
tup: tuple[Unpack[Ts]]
1380-
1381-
In fact, ``Unpack`` can be used interchangeably with ``*`` in the context
1382-
of types. You might see ``Unpack`` being used explicitly in older versions
1383-
of Python, where ``*`` couldn't be used in certain places::
1384-
1385-
# In older versions of Python, TypeVarTuple and Unpack
1386-
# are located in the `typing_extensions` backports package.
1387-
from typing_extensions import TypeVarTuple, Unpack
1388-
1389-
Ts = TypeVarTuple('Ts')
1390-
tup: tuple[*Ts] # Syntax error on Python <= 3.10!
1391-
tup: tuple[Unpack[Ts]] # Semantically equivalent, and backwards-compatible
1371+
A typing operator that conceptually marks an object as having been
1372+
unpacked. For example, using the unpack operator ``*`` on a
1373+
:class:`type variable tuple <TypeVarTuple>` is equivalent to using ``Unpack``
1374+
to mark the type variable tuple as having been unpacked::
1375+
1376+
Ts = TypeVarTuple('Ts')
1377+
tup: tuple[*Ts]
1378+
# Effectively does:
1379+
tup: tuple[Unpack[Ts]]
1380+
1381+
In fact, ``Unpack`` can be used interchangeably with ``*`` in the context
1382+
of types. You might see ``Unpack`` being used explicitly in older versions
1383+
of Python, where ``*`` couldn't be used in certain places::
1384+
1385+
# In older versions of Python, TypeVarTuple and Unpack
1386+
# are located in the `typing_extensions` backports package.
1387+
from typing_extensions import TypeVarTuple, Unpack
1388+
1389+
Ts = TypeVarTuple('Ts')
1390+
tup: tuple[*Ts] # Syntax error on Python <= 3.10!
1391+
tup: tuple[Unpack[Ts]] # Semantically equivalent, and backwards-compatible
13921392

13931393
.. versionadded:: 3.11
13941394

0 commit comments

Comments
 (0)