Skip to content

Commit e373264

Browse files
committed
Added suggested text from @srittau that clarifies illegal forms of unbounded tuples.
1 parent 51ff533 commit e373264

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/spec/tuples.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ compatible with any tuple of any length. This is useful for gradual typing.
3131
The type ``tuple`` (with no type arguments provided) is equivalent to
3232
``tuple[Any, ...]``.
3333

34+
Arbitrary-length tuples have exactly two type arguments -- the type and
35+
an ellipsis. Any other tuple form that uses an ellipsis is invalid::
36+
37+
t1: tuple[int, ...] # OK
38+
t2: tuple[int, int, ...] # Invalid
39+
t3: tuple[...] # Invalid
40+
t4: tuple[..., int] # Invalid
41+
t5: tuple[int, ..., int] # Invalid
42+
t6: tuple[*tuple[str], ...] # Invalid
43+
t7: tuple[*tuple[str, ...], ...] # Invalid
44+
3445

3546
Unpacked Tuple Form
3647
-------------------

0 commit comments

Comments
 (0)