mypy: Fix new issues in models.completionmodel

This commit is contained in:
Florian Bruhin 2019-10-22 16:23:20 +02:00
parent 87c642d07b
commit 31903163be
1 changed files with 5 additions and 3 deletions

View File

@ -43,7 +43,8 @@ class CompletionModel(QAbstractItemModel):
def __init__(self, *, column_widths=(30, 70, 0), parent=None):
super().__init__(parent)
self.column_widths = column_widths
self._categories = [] # type: typing.Sequence[QAbstractItemModel]
self._categories = [
] # type: typing.MutableSequence[QAbstractItemModel]
def _cat_from_idx(self, index):
"""Return the category pointed to by the given index.
@ -182,10 +183,11 @@ class CompletionModel(QAbstractItemModel):
# WORKAROUND:
# layoutChanged is broken in PyQt 5.7.1, so we must use metaObject
# https://www.riverbankcomputing.com/pipermail/pyqt/2017-January/038483.html
self.metaObject().invokeMethod(self, "layoutAboutToBeChanged")
self.metaObject().invokeMethod(self, # type: ignore
"layoutAboutToBeChanged")
for cat in self._categories:
cat.set_pattern(pattern)
self.metaObject().invokeMethod(self, "layoutChanged")
self.metaObject().invokeMethod(self, "layoutChanged") # type: ignore
def first_item(self):
"""Return the index of the first child (non-category) in the model."""