PyCharm not flagging overridden functions with Windows

I am migrating from a Macbook to a Windows laptop. This has revealed a problem which only shows up when PyCharm is running on my Windows laptop. Both laptops are running PyCharm Professional v3.1.1. Consider the following code fragment:

from PySide.QtGui import QWidget
class Example(QWidget):
    def keyPressEvent(self, key_event):
        pass
    def timerEvent(timer_event):
        pass

PySide is one of the numerous packages which do not conform to the PEP8 naming conventions. Hence, camelcase function names like keyPressEvent() and timerEvent() get flagged with PEP8 warnings if PyCharm does not correctly recognize them as overrides.

With Windows, the PyCharm editor flags keyPressEvent() as an override but not timerEvent(). With MAC OS X, both functions are correctly flagged as overrides.

Note that keyPressEvent() is a function of QWidget, whereas timerEvent() is a function of QObject [QObject is one of the two parent classes of QWidget].
2 comments
Comment actions Permalink
Hi Raymond,

please, navigate to QWidget (Ctrl+Click) on your MAC and tell if this file contains proper QWidget class declaration. Also I'm interested in """# by generator 1.133""" line on the top of file.
0
Comment actions Permalink
I updated both laptops to the latest available PyCharm Pro builds since my previous post here, after which the Windows laptop shows generator 1.133 and the Macbook shows generator 1.130. Ctrl-click of QWidget on both laptops correctly shows QWidget as being declared as a subclass of both QPaintDevice and QObject.

But, then I tried the same Ctrl-Click trick for QObject. I added 'from PySide.QtCore import QObject' to my code fragment and then ctrl-clicked Qobject. The Macbook shows QObject as one of many classes defined in a QtCore.py module. In contrast to that, the Windows laptop shows QObject as being the only class defined in a module of the same name [QObject.py]. This difference, no doubt, is due to the fact that Windows PySide was pip installed, whereas the Macbook PySide was port installed using MacPorts. I use MacPorts on the Mac specifically because MacPorts is really good at shaping source code to avoid issues such as this one on a Mac.

Ergo, this override issue is an anomaly caused by the PySide source which the MacPorts build of PySide corrects.

Unfortunately, knowing this does not resolve my problem on a Windows computer. Note that PyCharm is not entirely free of blame since it does, indirectly, know timerEvent() is an overridden function. The proof of this is that PyCharm's Structure window lists timerEvent as a function of QObject and it also lists QObject as one of the parents of QWidget.
0

Please sign in to leave a comment.