-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
False positive [override] check, superclass signature wrong #16437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is pure speculation, but the root cause of this might be the same as #16429. |
I looked at this a little but couldn't find anything. I suspect mypy may be looking at a different set of types for PyQt6 than you're using. I don't know what #16429 has to do with this issue. |
I'm not sure I understand what you're saying but I checked PyQt5 and this method has the same signature. It reproduces on my Fedora systems and also in the Ubuntu VMs in GitHub actions, plus using tox. If mypy is using the wrong
The only reason I suggested that is because the symptom is making stuff Optional when it's not. I don't mypy code at all, so this could simply be a coincidence. |
Mypy is flagging contextMenuEvent signature problems. This method does not have an optional event parameter. See: * python/mypy#16437 * https://doc.qt.io/qt-6/qwidget.html#contextMenuEvent * https://wiki.python.org/moin/PyQt/Handling%20context%20menus The mypy error looks like this: setoolsgui/widgets/views/treewidget.py:15: error: Argument 1 of "contextMenuEvent" is incompatible with supertype "QAbstractScrollArea"; supertype defines the argument type as "QContextMenuEvent | None" [override] def contextMenuEvent(self, event: QtGui.QContextMenuEvent) -> None: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ setoolsgui/widgets/views/treewidget.py:15: note: This violates the Liskov substitution principle setoolsgui/widgets/views/treewidget.py:15: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides setoolsgui/widgets/views/treewidget.py:15: error: Argument 1 of "contextMenuEvent" is incompatible with supertype "QWidget"; supertype defines the argument type as "QContextMenuEvent | None" [override] def contextMenuEvent(self, event: QtGui.QContextMenuEvent) -> None: Signed-off-by: Chris PeBenito <[email protected]>
Mypy is flagging contextMenuEvent signature problems. This method does not have an optional event parameter. See: * python/mypy#16437 * https://doc.qt.io/qt-6/qwidget.html#contextMenuEvent * https://wiki.python.org/moin/PyQt/Handling%20context%20menus The mypy error looks like this: setoolsgui/widgets/views/treewidget.py:15: error: Argument 1 of "contextMenuEvent" is incompatible with supertype "QAbstractScrollArea"; supertype defines the argument type as "QContextMenuEvent | None" [override] def contextMenuEvent(self, event: QtGui.QContextMenuEvent) -> None: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ setoolsgui/widgets/views/treewidget.py:15: note: This violates the Liskov substitution principle setoolsgui/widgets/views/treewidget.py:15: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides setoolsgui/widgets/views/treewidget.py:15: error: Argument 1 of "contextMenuEvent" is incompatible with supertype "QWidget"; supertype defines the argument type as "QContextMenuEvent | None" [override] def contextMenuEvent(self, event: QtGui.QContextMenuEvent) -> None: Signed-off-by: Chris PeBenito <[email protected]>
Mypy is flagging contextMenuEvent signature problems. This method does not have an optional event parameter. See: * python/mypy#16437 * https://doc.qt.io/qt-6/qwidget.html#contextMenuEvent * https://wiki.python.org/moin/PyQt/Handling%20context%20menus The mypy error looks like this: setoolsgui/widgets/views/treewidget.py:15: error: Argument 1 of "contextMenuEvent" is incompatible with supertype "QAbstractScrollArea"; supertype defines the argument type as "QContextMenuEvent | None" [override] def contextMenuEvent(self, event: QtGui.QContextMenuEvent) -> None: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ setoolsgui/widgets/views/treewidget.py:15: note: This violates the Liskov substitution principle setoolsgui/widgets/views/treewidget.py:15: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides setoolsgui/widgets/views/treewidget.py:15: error: Argument 1 of "contextMenuEvent" is incompatible with supertype "QWidget"; supertype defines the argument type as "QContextMenuEvent | None" [override] def contextMenuEvent(self, event: QtGui.QContextMenuEvent) -> None: Signed-off-by: Chris PeBenito <[email protected]>
Bug Report
mypy is using an incorrect method signature on [override] checks. The code looks like this:
Full code: https://github.com/pebenito/setools/blob/pyqt-rework/setoolsgui/widgets/views/treewidget.py
When inspecting the PyQt6 definitions, the contextMenuEvent() parameter is not optional:
Expected Behavior
No errors
Actual Behavior
Example run: https://github.com/pebenito/setools/actions/runs/6804093923/job/18500854778#step:8:36
Your Environment
This is running in tox. I hit this both on my Fedora 38 system and also GitHub actions (Ubuntu). tox.ini if useful: https://github.com/pebenito/setools/blob/pyqt-rework/tox.ini
-p
to specify packagemypy.ini
(and other config files): from pyproject.tomlThe text was updated successfully, but these errors were encountered: