Stub method being overshadowed by module #690
Description
With the new PyTorch type stubs (pytorch/pytorch#12500), the stub for the tensor
method seems to not be utilized by intellisense (example below). I think this is related to the existence of a module called tensor.py
in the PyTorch package - if I delete that file, then the stub is utilized. Maybe the language server is somehow getting confused between whether torch.tensor
should be inferred to refer to the module or the method defined in the stub. In this case, it should refer to the stub.
The stub for tensor
indicates it has a Tensor
return type, but we see vscode not showing Tensor
methods here:
Meanwhile the similar as_tensor
method, which has the same return type, is working:
Here are the stub definitions:
def tensor(data: Any, dtype: Optional[_dtype]=None, device: Union[_device, str, None]=None, requires_grad: bool=False) -> Tensor: ...
def as_tensor(data: Any, dtype: _dtype=None, device: Optional[_device]=None) -> Tensor: ...
I don't have a minimal example at the moment. PyTorch is a big package and in my simple attempts to reduce the problem to a minimal version, VSCode did the right thing, so it's hard for me to tell what exactly is going wrong.
This is with Python 3.7, extension version 2019.5.5433 and VSCode 1.31.1.