🐛 Bug
after updating to pytorch 1.6 mypy does not recognise the tensor attributes ndim
, nonzero
and T
.
The mypy errors are:
error: “Tensor” has no attribute “T”
error: “Tensor” has no attribute “ndim”
error: “Tensor” has no attribute “nonzero”
Expected behavior
No errors
Environment
- PyTorch 1.6
before updating to pytorch 1.6. everything was working fine.
The
nonzero
omission may have been intentional becauseTensor.nonzero()
is deprecated. Weirdly enoughTensor.nonzero(as_tuple=...)
is not deprecated, but that may be an error in how the deprecation was implemented – I assume the whole method will be removed.Other deprecated functions and methods still have annotations though, and in
gen_pyi.py
there’s aTODO: maybe we shouldn't genrate type hits for deprecated functions
note, but that has drawbacks as well. So I opened a PR to add back the annotation.