From 3d93e1537836e91580eae32714f440626a2a1e15 Mon Sep 17 00:00:00 2001 From: toofar Date: Sun, 11 Sep 2022 14:19:49 +1200 Subject: mypy: add hints and comments around QKeySequence Mypy doesn't seem to know that QKeySequence is an iterable, so it complains about itertools not handling it. And since we lose type information there we have to add it back in a couple of places. --- qutebrowser/keyinput/keyutils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/qutebrowser/keyinput/keyutils.py b/qutebrowser/keyinput/keyutils.py index 92ef717af..6016d61f4 100644 --- a/qutebrowser/keyinput/keyutils.py +++ b/qutebrowser/keyinput/keyutils.py @@ -547,7 +547,10 @@ class KeySequence: def __iter__(self) -> Iterator[KeyInfo]: """Iterate over KeyInfo objects.""" - for combination in itertools.chain.from_iterable(self._sequences): + combination: QKeySequence + for combination in itertools.chain.from_iterable( + self._sequences # type: ignore[arg-type] + ): yield KeyInfo.from_qt(combination) def __repr__(self) -> str: @@ -719,7 +722,7 @@ class KeySequence: mappings: Mapping['KeySequence', 'KeySequence'] ) -> 'KeySequence': """Get a new KeySequence with the given mappings applied.""" - infos = [] + infos: List[KeyInfo] = [] for info in self: key_seq = KeySequence(info) if key_seq in mappings: -- cgit v1.2.3-54-g00ecf