mypy icon indicating copy to clipboard operation
mypy copied to clipboard

`reveal_type()` cannot get `*Ts` type of the instance of a generic class

Open hyperkai opened this issue 1 month ago • 1 comments

*Memo:

  • mypy --strict test.py
  • mypy 1.19.0
  • Python 3.14.0
  • Windows 11

reveal_type() can get T type of the instance of a generic class as shown below:

class MyCls[T = int]:

    def __init__(self, x: T | None = None) -> None: ...

reveal_type(MyCls()) # builtins.int

But reveal_type() cannot get *Ts type of the instance of a generic class as shown below:

class MyCls[*Ts = *tuple[int, ...]]:

    def __init__(self, *args: *Ts) -> None: ...

reveal_type(MyCls()) # ()

hyperkai avatar Dec 09 '25 18:12 hyperkai

Could you explain the problem? () aka empty tuple is the only correct parameterization here, what output do you expect? Zero args form an empty tuple, and MyCls[()] is what mypy prints for your example.

sterliakov avatar Dec 10 '25 17:12 sterliakov