Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Stub method being overshadowed by module #690

Closed
@malmaud

Description

@malmaud

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:

screen shot 2019-03-02 at 5 00 39 pm

Meanwhile the similar as_tensor method, which has the same return type, is working:
screen shot 2019-03-02 at 5 01 03 pm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions