Type "Shape[int]" is not assignable to declared type "Shape[int]"
- Dominant language
- Python
- Stars
- 15.6k
- Forks
- 1.8k
- Avg merge
- 12h 13m
- Merged PRs (30d)
- 52
Description
```py
class Shape[*Ts](tuple[*Ts]): ...
reveal_type(Shape([42]))
s1: Shape[int] = Shape([42])
```
reports
- ```
Type of "Shape([42])" is "Shape[int]"
```
- ```
Type "Shape[int]" is not assignable to declared type "Shape[int]"
"Untitled.Shape" is not assignable to "Untitled.Shape"
Type parameter "Ts@Shape" is invariant, but "int" is not the same as "*tuple[int]" (reportAssignmentType)
```
which is... odd
[playground](https://pyright-play.net/?pyrightVersion=1.1.400&pythonVersion=3.14&strict=true&code=MYGwhgzhAEDKAWYAOBTA2gKgCoQLoAoAXAVyRHWzwEoAuaAOkYCgmAnFANxTBAH1CAnqnwJkKfGgAsAJlxUq0RUoDEcRKjQBLAHaFcTCAEY6ojTr3QAvGrESZcxaoCiddkgD2rQgEEomgObaALYoulhCKExAA)
Contributor guide
Research direction
Start with the linked playground reproduction using Pyright 1.1.400, Python 3.14, and strict mode. Trace how the variadic generic Shape[int] is inferred and then checked against the annotated assignment. Done means the example no longer reports a self-incompatibility while preserving the revealed type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100