【发布时间】:2020-08-29 16:25:26
【问题描述】:
我使用我的编码环境已经有一段时间了。这个问题是最近在升级 pylint 或 VS-code 之后发生的。
我的设置是:
VS-Code + Python 3.7(anaconda) + pylint 2.5.0
我在 VS-Code 中使用的一些扩展是:Anaconda Extension Pack、Qt for Python
这是重现此问题所需的最少代码:
#!/usr/bin/env python3
"""
A demo for pylint
"wrapped C/C++ object of type QApplication has been deleted"
false positive
"""
import sys
from PyQt5 import QtWidgets
class Window(QtWidgets.QMainWindow):
"""A simple window"""
def __init__(self):
super(Window, self).__init__()
self.variable = 1 # This line triggers the alarm.
self.show()
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
newWindow = Window()
sys.exit(app.exec_())
显然,没有任何真正的问题。上面的代码可以正常运行。
与此同时,pylint 一直在抱怨:
QApplication 类型的封装 C/C++ 对象已被删除
通常我不会打扰。但是,此错误会阻止 pylint 进行迭代。
有人知道是什么让皮林特不开心吗?
PS,这是我的 VS-Code 的 settings.json
{
"editor.renderWhitespace": "selection",
"editor.tabCompletion": "on",
"files.eol": "\n",
"telemetry.enableCrashReporter": false,
"telemetry.enableTelemetry": false,
"window.autoDetectHighContrast": false,
"window.zoomLevel": 0,
"git.autofetch": true,
"python.dataScience.notebookFileRoot": "${fileDirname}",
"python.terminal.executeInFileDir": true,
"python.linting.pylintEnabled": true,
"python.linting.pycodestyleEnabled": true,
"python.linting.enabled": true,
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=PyQt5",
"--generated-members=numpy.*, torch.*, PyQt5.*",
"--disable=invalid-name, protected-access, E1102"
],
"python.dataScience.sendSelectionToInteractiveWindow": false,
"workbench.colorTheme": "Monokai",
}
我刚刚设置了一个干净的虚拟机,并使用这些软件包的不同版本进行了快速测试。 事实证明,这个问题是从 pylint 2.5.0 开始引入的。 Pylint 2.4.4 很好。
看起来更像是一个错误而不是一个问题。反正..
我在 Github 上打开了一个问题,看看你们是否遇到了类似的问题: #3617 它可能也与astroid有关。我真的不在乎,我会坚持使用 2.4.4,直到出现更好的解决方案。
【问题讨论】:
标签: python visual-studio-code pyqt pyqt5 pylint