Skip to content

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

@hyperkai

Description

@hyperkai

*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()) # ()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongpendingIssues that may be closed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions