-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Closed
Labels
module: typingRelated to mypy type annotationsRelated to mypy type annotationstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
🐛 Bug
import torch
a = torch.Tensor().ndim # mypy says: `error: "Tensor" has no attribute "ndim"`
Environment
torch 1.6.0 and master (ecb9e79)
Why this occurs and how to solve
#38157 removed torch/__init__.pyi.in
and introduced torch/_C/__init__.pyi.in
, but some methods defined in torch/__init__.pyi.in
(ndim
, T
, and grad_fn
) was not salvaged and had gone away.
T
and grad_fn
was rescued in #40658. Only the ndim
is still not typed.
The solution wolud be just adding ndim
attribute to _TensorBase
in torch/_C/__init__.pyi.in
.
Metadata
Metadata
Assignees
Labels
module: typingRelated to mypy type annotationsRelated to mypy type annotationstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module