Pylint 无法识别 gmpy2 成员

Pylint cannot recognize gmpy2 members

我在 Kali Linux(WSL2) 上使用 pylint 和 gmpy2。 Pylint 多次抱怨无法找到 gmpy2 成员。我怎样才能避免这种情况?

这是一个小例子:

import gmpy2
print(gmpy2.is_even(6))

而pylint的结果是

tst.py:2:6: E1101: Module 'gmpy2' has no 'is_even' member (no-member)

我在Arch上也试过了Linux,结果是一样的

根据 document

If you are getting the dreaded no-member error, there is a possibility that either pylint found a bug in your code or that it actually tries to lint a C extension module.

Linting C extension modules is not supported out of the box, especially since pylint has no way to get an AST object out of the extension module.

您应该在命令行或 pylintrc 文件中添加 extension-pkg-whitelist 参数。

这里是我在Github打开的issue原文。