How do I get PyLint to recognize numpy members?

2019-01-16 03:56发布

I am running PyLint on a Python project. PyLint makes many complaints about being unable to find numpy members. How can I avoid this while avoiding skipping membership checks.

From the code:

import numpy as np

print np.zeros([1, 4])

Which, when ran, I get the expected:

[[ 0. 0. 0. 0.]]

However, pylint gives me this error:

E: 3, 6: Module 'numpy' has no 'zeros' member (no-member)

For versions, I am using pylint 1.0.0 (astroid 1.0.1, common 0.60.0) and trying to work with numpy 1.8.0 .

19条回答
一纸荒年 Trace。
2楼-- · 2019-01-16 04:21

There have been many different bugs reported about this over the past few years i.e. https://bitbucket.org/logilab/pylint/issue/58/false-positive-no-member-on-numpy-imports

I'd suggest disabling for the lines where the complaints occur.

# pylint: disable=E1103
print np.zeros([1, 4])
# pylint: enable=E1103
查看更多
登录 后发表回答