Pyright error when using TypeVarTuple


Pyright shows errors with the following code using TypeVarTuple. How can I fix it?

from typing import TypeVarTuple

Ts = TypeVarTuple("Ts")

def f(arg: tuple[*Ts]) -> tuple[int, *Ts]:
    ret = (1,) + arg
    return ret

x:tuple[int, str] = (1, 'a')
value = f(x)


$ pyright --version
pyright 1.1.327

$ pyright
  /Users/inoue/ - error: Expression of type "tuple[Union[*Ts@f] | Literal[1], ...]" cannot be assigned to return type "tuple[int, *Ts@f]"
    "tuple[Union[*Ts@f] | Literal[1], ...]" is incompatible with "tuple[int, *Ts@f]"
      Tuple entry 1 is incorrect type
        Type "object | Literal[1]" cannot be assigned to type "int"
          "object" is incompatible with "int" (reportGeneralTypeIssues)
1 error, 0 warnings, 0 informations

The __add__ method for tuple doesn’t preserve the TypeVarTuple. If you use a tuple expression instead, you can eliminate the type error.

def f(arg: tuple[*Ts]) -> tuple[int, *Ts]:
    ret = (1, *arg)
    return ret

It works!
Thank you!