Skip to content

TypeVarTuple equality checks not implemented #16739

@cdce8p

Description

@cdce8p

Bug Report
PEP 646 mentions equality checks for TypeVarTuples inside the same signature. These don't seem to be implemented yet.
https://peps.python.org/pep-0646/#type-variable-tuple-equality

/CC: @ilevkivskyi

To Reproduce

These examples are from the PEP itself

from typing import Generic, TypeVarTuple
Ts = TypeVarTuple("Ts")

class Array(Generic[*Ts]): ...

def pointwise_multiply(x: Array[*Ts], y: Array[*Ts]) -> Array[*Ts]: ...

def a1(x: Array[int], y: Array[str], z: Array[int, str]) -> None:
    pointwise_multiply(x, x)  # Valid
    pointwise_multiply(x, y)  # Error
    pointwise_multiply(x, z)  # Error


# ---
def foo(arg1: tuple[*Ts], arg2: tuple[*Ts]) -> None: ...

def a2(a: tuple[int], b: tuple[str]) -> None:
    foo(a, b)  # Error

An additional example

def func(x: Array[*Ts], *args: *Ts) -> None:
    ...

def a3(x: Array[int, str]) -> None:
    func(x, 2, "Hello")  # Valid
    func(x, 2)                  # Error
    func(x, 2, "Hello", True)   # Error

Your Environment

  • Mypy version used: mypy 1.9.0+dev.a1b4e32785b69291748579d97cb9456e1198ec21
  • Python version used: 3.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-pep-646PEP 646 (TypeVarTuple, Unpack)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions