QAbstractItemModel parent() Stubs
Unsolved
Qt for Python
-
Hi everyone,
I have been subclassing QAbstractItemModel recently and noticed that in the stub file parent() has 2 overloads:
@overload def parent(self) -> QObject: ...
and
@overload def parent(self, row:int, column:int, parent:QModelIndex)->QModelIndex: ...
If I'm not mistaken shouldn't overloads have same number of arguments (just different types) as python typing.overload does not support variable number of args?
How would you go about subclassing so that a static type checker (Pyright in my case) does not complain?
-
Hi and welcome to devnet,
That likely comes from the fact that the base C++ classe has these two methods that are very different in what they return. The former returns the QObject class that is the parent of this one (Qt parent/child management) while the latter, which is related to the model itself, looks wrong as it should only have an item as parameter.