Sublime Pylint PyQt4 模块没有成员

Sublime Pylint PyQt4 Module has no member

我正在使用安装了 SublimeLinter + SublimeLinter-pylint 的 Sublime-Text3。
一切都按预期工作,除了 pylint "scanning" PyQt4

from PyQt4 import QtCore, QtGui

工作正常。 Pylint检测到QtCore和QtGui,但是如果

button = QtGui.QPushButton()
layout = QtGui.QVBoxLayout()

pylint 设置红色下划线并告知

PyQt4.QtGui has no "QPushButton" member

有什么方法可以修复这个错误或者忽略 SublimeLinter 中的 PyQt 吗?

最新版本的 pylint 不再加载扩展模块(即编译后的代码不是用纯 python 编写的),除非使用 extension-pkg-whitelist 选项列出它们。这是因为加载扩展模块需要实际加载可能会触发不良副作用的代码。

对于您的情况,pylint --extension-pkg-whitelist=PyQt4 <your module>(或在配置文件中使用等效条目)应该可以解决您的问题。

找到解决方案,感谢 sthenault

循序渐进。

  1. 生成rc文件

pylint --generate-rcfile > pylint.rc

  1. 替换行

extension-pkg-whitelist=

来自

extension-pkg-whitelist=PyQt4

  1. 崇高

Preferences -> Package Settings -> SublimeLinter -> Settings - User

"pylint": {
            [..another settings..]
            "rcfile": "/path_to_rc/pylint.rc",
        }