Cannot fix PyCharm warnings in simple PyQt program

The following program (excerpt from my real code)

from PyQt4 import QtGui
import sys
from PyQt4.QtGui import QMessageBox


def main():
    app = QtGui.QApplication([])

    w = QtGui.QPushButton("Test")

    def on_pressed():
        print("Pressed")
        QMessageBox.warning(w, 'Info', 'Button Pressed')

    w.pressed.connect(on_pressed)
    w.show()

    sys.exit(app.exec_())


if __name__ == '__main__':
    main()

triggers the following three warnings in PyCharm (e.g. at startup Code/Inspect Code...) related to a callQMessageBox.warning

  • Calling a method on a class using an instance of another class; Passing PyQt4.QtGui.QPushButton.QPushButton instead of PyQt4.QtGui.QMessageBox.QMessageBox. Is it intentional?

  • Invalid call arguments; QString_1 is empty

  • Type check; The expected type is "QMessageBox", instead "QPushButton"

and one warning related to calling PyQt connect

  • Unable to find link 'connect' in 'function'

Any idea how I can get around / avoiding these warnings?

+4

Source: https://habr.com/ru/post/1674131/


All Articles