Clarification regarding override checking #6265
Replies: 1 comment 2 replies
-
According to https://typing.readthedocs.io/en/latest/source/stubs.html#id22:
It seems that changing the PySide6.QtCore.QEvent argument to be prefixed by two underscores all across the inheritance hierarchy (PySide6.QtCore.QPauseAnimation -> PySide6.QtCore.QAbstractAnimation -> PySide6.QtCore.QObject) stops the PylancereportIncompatibleMethodOverride error. Can I use this to fix the error without any side effects? |
Beta Was this translation helpful? Give feedback.
-
I'm updating PySide6, which offers the official Python bindings for Qt, to offer primary support for pyright and a more complete python (strict) typing experience. I need clarification regarding how overriding is checked. I can't find any specific information in the PEP (https://peps.python.org/pep-0698/). The pyright docs states:
It states that wrong number of parameters, incompatible parameter types, or incompatible return type are all detected as incompatible overrides. Pylance detects the following as incompatible:
For parameters that can be used with keyword arguments, variable name checking is essential. But is it for positional-only parameters? Isn't it possible, in theory, for type checkers to differentiate between the two situations?
The event method in QPauseAnimation has the QEvent variable named as e. That is a direct consequence of the binding generator tool (Shiboken6), which reads the C++ headers and generates a function signature that is then used to generate stub files (.pyi). I can fix this in the stub files generation stage by telling it to rename to event or the same name as in the base class.
Beta Was this translation helpful? Give feedback.
All reactions