Pylint: False positive for `no-member` while using torch

Created on 25 Apr 2020  路  4Comments  路  Source: PyCQA/pylint

Hi,
I submit this issue in VScode, turn out it should be here.
You can see the discussion: https://github.com/microsoft/vscode-python/issues/11213

Just as the topic said, I have tried lots of methods online, but None is effective.
One suggests add the code in pylint,''generated-members=numpy.,torch.''
Yes, it works for some code(some still have a red line), but other errors can't be marked it out either because of adding the code.
It troubled me a lot, I like VScode, but this is really annoying problem.

duplicate question

Most helpful comment

You can also disable them one by one with #聽pylint: disable=no-member, if you want to keep the others.

You're right that no-member should not have false positive. It's complicated to fix because the information is contained in C binding. So the fix is probably not going to be quick. Pull request would be welcome as torch is not the only package affected by this :)

All 4 comments

@JonOnEarth , in order to fix this you, can add a file called .pylintrc at the root of your project containing this:

[MESSAGES CONTROL]

disable=
    no-member,

You can add other error messages after the comma if you want.

This is why we need to disable false positives by default in #3512

Thanks. It absolutely works. But it also can cause some other problems.
For example, some typo errors will not be pointed it out because of this no-member.

The best solution still needs pylint support Pytorch or torch I assume.

You can also disable them one by one with #聽pylint: disable=no-member, if you want to keep the others.

You're right that no-member should not have false positive. It's complicated to fix because the information is contained in C binding. So the fix is probably not going to be quick. Pull request would be welcome as torch is not the only package affected by this :)

I'm closing not because it's invalid but because we have multiple tickets regarding false positive with no-member for libraries with C-binding.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pylint-bot picture pylint-bot  路  3Comments

glmdgrielson picture glmdgrielson  路  3Comments

PCManticore picture PCManticore  路  3Comments

ethanchewy picture ethanchewy  路  3Comments

z4y4ts picture z4y4ts  路  3Comments