Closed
Description
🚀 The feature, motivation and pitch
There are several issues with the current type hints for torch.Size
:
pytorch/torch/_C/__init__.pyi.in
Lines 172 to 180 in 9f94710
It simply subclasses tuple[int, ...]
, but this causes several typing errors, for example:
import torch
x = torch.Size([1,2,3])
y = torch.Size([4,5,6])
reveal_type(x+y) # tuple[int, ...], not Size !!!
This is because tuple.__add__
is annotated to return tuple
.
Alternatives
No response
Additional context
No response