You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to implement a protocol that mimics QFileSystemModel so that I can use that protocol to define a new custom class. The protocol definition is generating a mypy error ( error: Definition of "index" in base class "QAbstractItemModel" is incompatible with definition in base class "FileSystemModelProtocol")
I've checked with pyright and pytype and neither report an error.
To Reproduce
importtypingfromPyQt6importQtCore, QtGuiclassFileSystemModelProtocol(typing.Protocol):
"""Define the subset of QFileSystemModel methods used...for defining a class with the same behavior"""@typing.overloaddefindex(self, row: int, column: int, parent: QtCore.QModelIndex= ...) ->QtCore.QModelIndex: ...
@typing.overloaddefindex(self, row: typing.Optional[str], column: int= ...) ->QtCore.QModelIndex: ...
defindex(self, row: typing.Optional[int|str] = ..., column: int= ..., parent: QtCore.QModelIndex= ...) ->QtCore.QModelIndex: ...
classCustomFileSystemModel(QtGui.QFileSystemModel, FileSystemModelProtocol): # error: Definition of "index" in base class "QAbstractItemModel" is incompatible with definition in base class "FileSystemModelProtocol"passclassTableModel(QtCore.QAbstractTableModel, FileSystemModelProtocol):
defindex_from_str(self, path: str) ->QtCore.QModelIndex:
returnQtCore.QModelIndex() # TODO: lookup with pathdefindex(self, row: typing.Optional[int|str] =None, column: int=0, parent: QtCore.QModelIndex=QtCore.QModelIndex()) ->QtCore.QModelIndex:
ifisinstance(row, str):
returnself.index_from_str(row)
ifisinstance(row, int):
returnsuper().index(row, column, parent)
returnQtCore.QModelIndex()
c=CustomFileSystemModel()
t=TableModel()
Expected Behavior
No errors, or a better explanation of what is wrong.
Actual Behavior
error: Definition of "index" in base class "QAbstractItemModel" is incompatible with definition in base class "FileSystemModelProtocol" [misc]
Your Environment
Mypy version used:
mypy 1.9.0 (compiled: yes)
Mypy command-line flags:
none
Mypy configuration options from mypy.ini (and other config files):
none
Python version used:
Python 3.11.7
PyQt6==6.6.1
The text was updated successfully, but these errors were encountered:
I'm trying to implement a protocol that mimics QFileSystemModel so that I can use that protocol to define a new custom class. The protocol definition is generating a mypy error ( error: Definition of "index" in base class "QAbstractItemModel" is incompatible with definition in base class "FileSystemModelProtocol")
I've checked with pyright and pytype and neither report an error.
To Reproduce
Expected Behavior
No errors, or a better explanation of what is wrong.
Actual Behavior
error: Definition of "index" in base class "QAbstractItemModel" is incompatible with definition in base class "FileSystemModelProtocol" [misc]
Your Environment
mypy.ini
(and other config files):Python 3.11.7
PyQt6==6.6.1
The text was updated successfully, but these errors were encountered: