KEMBAR78
Broken `Type Hints` in PyTorch 0.4.0, related to IDEs(eq. PyCharm) · Issue #7318 · pytorch/pytorch · GitHub
Skip to content

Broken Type Hints in PyTorch 0.4.0, related to IDEs(eq. PyCharm) #7318

@kimdwkimdw

Description

@kimdwkimdw

If you have a question or would like help and support, please ask at our
forums.

If you are submitting a feature request, please preface the title with [feature request].
If you are submitting a bug report, please fill in the following details.

Issue description

Recently, I figured out PyCharm cannot make auto-complete for torch.zeros.

PyCharm says

Cannot find reference 'zeros' in '__init__.py'

I dig it for a while I found broken Type Hints.

From these changes,
30ec06c
https://github.com/pytorch/pytorch/wiki/Breaking-Changes-from-Variable-and-Tensor-merge

Especially, 30ec06c#diff-14258fce7c17ccb97b488e64373b0803R308 @colesbury
This line cannot make Type Hints for lots of IDEs.

Originally, torch.zeros was in torch/_C/__init__.py
But, it moved to torch/_C/_VariableFunctions

Code example

https://gist.github.com/kimdwkimdw/50c18b5cf72c69c2d01bb4146c8a2b5c
This is Proof of Concept for this bug.

If you look at main.py

import T_B as torch

torch.p2()  # IDE can detect `p2`
torch.p1    # IDE cannot detect `p1`

System Info

Please copy and paste the output from our
environment collection script
(or fill out the checklist below manually).

You can get the script and run it with:

wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
  • PyTorch or Caffe2:

  • How you installed PyTorch (conda, pip, source):
    Any case for conda, pip, source.

  • Build command you used (if compiling from source):

  • OS: Any

  • PyTorch version: 0.4.0

  • Python version: 3.6.5

  • CUDA/cuDNN version: .

  • GPU models and configuration: .

  • GCC version (if compiling from source): .

  • CMake version: .

  • Versions of any other relevant libraries:.

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