Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pylint no member issue but code still works vscode

I have a very simple code here

import torch

l = torch.nn.Linear(2,5)
v = torch.FloatTensor([1, 2])
print(l(v))

under torch.FloatTensor, pylint in visual studio code claims that 'Module torch has no 'FloatTensor' member pylint(no-member).

However, the code works fine. Is this a false positive? How can I disable pylint for this specific instance?

like image 983
Evan Kim Avatar asked Jul 02 '19 01:07

Evan Kim


People also ask

Does pylint have no member?

If you are getting the dreaded no-member error, there is a possibility that either: pylint found a bug in your code. You're launching pylint without the dependencies installed in its environment. pylint would need to lint a C extension module and is refraining to do so.

How do I disable VS Code pylint warnings?

You can easily toggle between enabling and disabling your linter. To switch, open the Command Palette (Ctrl+Shift+P) and select the Python: Enable/Disable Linting command. This will populate a dropdown with the current linting state and options to Enable or Disable Python linting.


1 Answers

  1. Press: CTRL + Shift + P

  2. Click on "Preferences: Open Settings (JSON)"

  3. Add this line into JSON : "python.linting.pylintArgs": ["--generated-members", "from_json,query"]


like image 114
Vaitul Bhayani Avatar answered Sep 20 '22 11:09

Vaitul Bhayani