Skip to content

Commit

Permalink
Added suggested text from @srittau that clarifies illegal forms of un…
Browse files Browse the repository at this point in the history
…bounded tuples.
  • Loading branch information
erictraut committed Jan 21, 2024
1 parent 51ff533 commit e373264
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/spec/tuples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ compatible with any tuple of any length. This is useful for gradual typing.
The type ``tuple`` (with no type arguments provided) is equivalent to
``tuple[Any, ...]``.

Arbitrary-length tuples have exactly two type arguments -- the type and
an ellipsis. Any other tuple form that uses an ellipsis is invalid::
t1: tuple[int, ...] # OK
t2: tuple[int, int, ...] # Invalid
t3: tuple[...] # Invalid
t4: tuple[..., int] # Invalid
t5: tuple[int, ..., int] # Invalid
t6: tuple[*tuple[str], ...] # Invalid
t7: tuple[*tuple[str, ...], ...] # Invalid


Unpacked Tuple Form
-------------------
Expand Down

0 comments on commit e373264

Please sign in to comment.