[ty] Ban multiple unpacked variadic tuples in a tuple specialization by AlexWaygood · Pull Request #22884 · astral-sh/ruff (original) (raw)

Summary

The spec states that while this is allowed:

tuple[*tuple[int, ...], *tuple[str]]

and this is allowed:

from typing import TypeVarTuple

Ts = TypeVarTuple("Ts")

tuple[*Ts, *tuple[str]]

none of these are, because multiple variadic tuples cannot be unpacked in the context of a single tuple specialization:

tuple[*tuple[int, ...], *tuple[str, ...]] tuple[*tuple[int, ...], str, *tuple[bytes, ...]] tuple[*Ts, *Ts] tuple[*Ts, *tuple[int, ...]]

This PR adds the missing diagnostics.

Test Plan

snapshots and mdtests