tuples_type_compat error

Tuple starred-unpack type compatibility violation

Detects assignments where a tuple literal or a tuple-typed variable is assigned to a target whose annotation contains a starred unpack expression (tupleT, ... or tupleT) and the assignment is incompatible with that annotation.

Covers module-level bare reassignments of annotated tuple variables and function-body variable assignments.

## Examples

t1: tuple[int, *tuple[str]] = (1, "")  # OK
t1 = (1, "", "")  # E — too many elements for *tuple[str]

t2: tuple[int, *tuple[str, ...]] = (1, "")  # OK
t2 = (1, 1, "")  # E — second element must be str

def f(t1: tuple[int], t2: tuple[int, *tuple[int, ...]], t3: tuple[int, ...]):
    v2: tuple[int, *tuple[int, ...]]
    v2 = t3  # E — homogeneous tuple[int,...] not assignable to mixed starred form
    v3: tuple[int]
    v3 = t2  # E — t2 may have more elements than v3 allows
    v3 = t3  # E — t3 is unbounded, v3 is fixed length 1

# Specification

<https://typing.readthedocs.io/en/latest/spec/tuples.html#type-compatibility-rules>

How to handle it

Every rule is on by default — strict is the default, not a cage. You can dial tuples_type_compat down per-file or per-path from your editor or pyproject.toml, or fix the code so it type-checks. See the Type System rules and the complete diagnostic reference.

Canonical URL: https://www.basilisk-python.dev/errors/tuples_type_compat