diff options
author | toofar <toofar@spalge.com> | 2022-09-11 14:19:49 +1200 |
---|---|---|
committer | toofar <toofar@spalge.com> | 2022-09-11 17:22:50 +1200 |
commit | 3d93e1537836e91580eae32714f440626a2a1e15 (patch) | |
tree | 80bd12fdd95f38643f1bc280a4575d0692a07816 | |
parent | 2eacf0456a7b5e7c7cb519e59c191dc257752214 (diff) | |
download | qutebrowser-3d93e1537836e91580eae32714f440626a2a1e15.tar.gz qutebrowser-3d93e1537836e91580eae32714f440626a2a1e15.zip |
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.
-rw-r--r-- | qutebrowser/keyinput/keyutils.py | 7 |
1 files 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: |