Skip to content Skip to sidebar Skip to footer

Pycharm Showing Wrong Parameter Info For Pyqt Methods

I don't do a lot of work in GUI's, but I've decided to move from occasionally using PyQt4 to PyQt5. My IDE is giving me warnings about some of the __init__ functions, particularly

Solution 1:

The correct signature is this:

QMainWindow(parent: QWidget = None,
            flags: Union[Qt.WindowFlags, Qt.WindowType] = Qt.WindowFlags())

So it looks like the IntelliSense in your IDE either does not know how to parse type-hints properly, or the necessary stub files aren't installed. There are only two arguments: parent and flags, both of which have defaults.

(NB: you should never use self.__class__ with super as it can lead to an infinite recursion under certain circumstances. Always pass in the subclass as the first argument - unless you're using Python 3, in which case you can omit all the arguments).

Solution 2:

Installing pyQt5-stubs will fix this error.

Post a Comment for "Pycharm Showing Wrong Parameter Info For Pyqt Methods"