Ask questionsLinting for certain pytorch classes missing
<!-- Do you have a question instead of a bug report or enhancement request? Please ask it on https://stackoverflow.com/questions/tagged/visual-studio-code+python.
Unable to install a linter or formatter? 'No installers available'? Windows - https://stackoverflow.com/questions/4750806/how-do-i-install-pip-on-windows Linux - https://www.cyberciti.biz/faq/debian-ubuntu-centos-rhel-linux-install-pipclient/ , https://www.tecmint.com/install-pip-in-linux/
Python configuration issues? Please check https://code.visualstudio.com/docs/python/python-tutorial#_prerequisites
Otherwise please fill in the requested details below. "XXX" markers should not be present in the final bug report.
If you think a GIF of what is happening would be helpful, consider tools like https://www.cockos.com/licecap/, https://github.com/phw/peek or https://www.screentogif.com/ . -->
pytorch 1.1.0
, pylint
Linting should work for pytorch
classes like torch.tensor
,torch.float
, torch.ones
, torch.zeros
and torch.zeros
Linting does not work. Shows a red line under torch
.
pytorch
classes.Output for Python
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python
)
Starting Jedi Python language engine.
##########Linting Output - pylint##########
************* Module rl
75,18,error,not-callable:torch.tensor is not callable
75,57,error,no-member:Module 'torch' has no 'float' member
96,34,error,no-member:Module 'torch' has no 'log' member
130,18,error,not-callable:torch.tensor is not callable
130,57,error,no-member:Module 'torch' has no 'float' member
150,12,error,not-callable:torch.tensor is not callable
151,17,error,no-member:Module 'torch' has no 'cat' member
160,38,error,no-member:Module 'torch' has no 'log' member
Output from Console
under the Developer Tools
panel (toggle Developer Tools on under Help
; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging
)
This issue https://github.com/pytorch/pytorch/issues/16996#issuecomment-491330553 has been fixed by pytorch on their end and the errors are with VS code. Another user https://github.com/pytorch/pytorch/issues/16996#issuecomment-492591199 has reported that the error does not appear with pycharm, but only with VS Code
Answer
questions
karrtikr
##########Linting Output - pylint##########
@Genius1237 You are using pylint
as your linter, and it seems like pylint
does not work well with pytorch
(See this). Please open this issue on their repository.
As a temporary fix, I suggest you to choose another suitable linter which supports pytorch
(flake8
seems to work fine). To do that,
Go to command palette Ctrl + Shift + P
-> Select linter
-> flake8
Related questions