Skip to content

Commit 57ae57e

Browse files
committed
Doc: Some improvements concern ellipsis into typing doc
1 parent a0dfdd4 commit 57ae57e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Doc/library/typing.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,11 @@ For example:
230230

231231
callback: Callable[[str], Awaitable[None]] = on_update
232232

233+
.. index:: single: ...; ellipsis literal
234+
233235
The subscription syntax must always be used with exactly two values: the
234236
argument list and the return type. The argument list must be a list of types,
235-
a :class:`ParamSpec`, :data:`Concatenate`, or an ellipsis. The return type must
237+
a :class:`ParamSpec`, :data:`Concatenate`, or an ellipsis (``...``). The return type must
236238
be a single type.
237239

238240
If a literal ellipsis ``...`` is given as the argument list, it indicates that
@@ -375,8 +377,11 @@ accepts *any number* of type arguments::
375377
# but ``z`` has been assigned to a tuple of length 3
376378
z: tuple[int] = (1, 2, 3)
377379

380+
.. index:: single: ...; ellipsis literal
381+
378382
To denote a tuple which could be of *any* length, and in which all elements are
379-
of the same type ``T``, use ``tuple[T, ...]``. To denote an empty tuple, use
383+
of the same type ``T``, use the literal ellipsis ``...``: ``tuple[T, ...]``.
384+
To denote an empty tuple, use
380385
``tuple[()]``. Using plain ``tuple`` as an annotation is equivalent to using
381386
``tuple[Any, ...]``::
382387

@@ -1162,6 +1167,8 @@ These can be used as types in annotations. They all support subscription using
11621167

11631168
Special form for annotating higher-order functions.
11641169

1170+
.. index:: single: ...; ellipsis literal
1171+
11651172
``Concatenate`` can be used in conjunction with :ref:`Callable <annotating-callables>` and
11661173
:class:`ParamSpec` to annotate a higher-order callable which adds, removes,
11671174
or transforms parameters of another

0 commit comments

Comments
 (0)