`reveal_type()` cannot get `*Ts` type of the instance of a generic class
Open
Nobody has claimed this yet.
bug
pending
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
*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()) # ()
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the example in test.py with mypy --strict and compare reveal_type() for T with the variadic *Ts case. Trace the generic-class inference path responsible for instance types, then add coverage showing the default tuple type is revealed as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100