如何让 Pylint 识别 NumPy 成员? [英] How do I get Pylint to recognize NumPy members?

查看:44
本文介绍了如何让 Pylint 识别 NumPy 成员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Python 项目上运行 Pylint.Pylint 抱怨无法找到 NumPy 成员.如何在避免跳过成员资格检查的同时避免这种情况?

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?

来自代码:

import numpy as np

print np.zeros([1, 4])

运行时,我得到了预期:

Which, when ran, I get the expected:

[[0.0.0.0.]]

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

但是,Pylint 给了我这个错误:

However, Pylint gives me this error:

E: 3, 6: 模块 'numpy' 没有 'zeros' 成员(无成员)

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

对于版本,我使用 Pylint 1.0.0(astroid 1.0.1,common 0.60.0)并尝试使用 NumPy 1.8.0.

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.

推荐答案

如果与 Don 一起使用 Visual Studio CodeJayamanne 的优秀Python 扩展,将用户设置添加到 NumPy 白名单:

If using Visual Studio Code with Don Jayamanne's excellent Python extension, add a user setting to whitelist NumPy:

{
    // Whitelist NumPy to remove lint errors
    "python.linting.pylintArgs": [
        "--extension-pkg-whitelist=numpy"
    ]
}

这篇关于如何让 Pylint 识别 NumPy 成员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆