Skip to content

Incorrect "self" keyword arguments in torch.__init__.pyi type hints  #40223

@MerHS

Description

@MerHS

🐛 Bug

Some PyTorch functions implemented in both torch.Tensor.* and torch.* share same type hints.

However from the official document page, torch.* functions use keyword input as the first argument, but torch.Tensor.* uses self keyword.

To Reproduce

  1. Find any function which the first argument has keyword self in site-packages/torch/__init__.pyi
  2. Use keyword input instead of self
  3. It works right in the console, but not in any Python type checker.

vscode

Expected behavior

console

Environment

PyTorch version: 1.5.0
Is debug build: No
CUDA used to build PyTorch: 10.1

OS: Ubuntu 18.04.4 LTS
GCC version: (Ubuntu 9.2.1-17ubuntu1~18.04.1) 9.2.1 20191102
CMake version: version 3.10.2

Python version: 3.8
Is CUDA available: Yes
CUDA runtime version: 10.0.130
GPU models and configuration: GPU 0: GeForce GTX 1080 Ti
Nvidia driver version: 430.50
cuDNN version: Could not collect

Versions of relevant libraries:
[pip] numpy==1.18.1
[pip] torch==1.5.0
[pip] torchfile==0.1.0
[pip] torchtext==0.5.0
[pip] torchvision==0.6.0a0+82fd1c8
[conda] blas                      1.0                         mkl  
[conda] cudatoolkit               10.1.243             h6bb024c_0  
[conda] mkl                       2020.1                      217  
[conda] mkl-service               2.3.0            py38he904b0f_0  
[conda] mkl_fft                   1.0.15           py38ha843d7b_0  
[conda] mkl_random                1.1.0            py38h962f231_0  
[conda] numpy                     1.18.1           py38h4f9e942_0  
[conda] numpy-base                1.18.1           py38hde5b4d6_1  
[conda] pytorch                   1.5.0           py3.8_cuda10.1.243_cudnn7.6.3_0    pytorch
[conda] torchfile                 0.1.0                    pypi_0    pypi
[conda] torchtext                 0.5.0                    pypi_0    pypi
[conda] torchvision               0.6.0                py38_cu101    pytorch
[conda] mypy                      0.770                      py_0  
[conda] mypy_extensions           0.4.3                    py38_0  

cc @ezyang

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: typingRelated to mypy type annotationstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions