summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2022-05-17 13:01:04 +0200
committerFlorian Bruhin <me@the-compiler.org>2022-06-22 17:41:12 +0200
commit1c9f93c4a66b8b1035fbba5b683c6592950cb40e (patch)
tree5322ebc3eb724a3115f33e80533bb3cd01d1a392
parente7c8a4afd3c39bbdb8983bb08ed98ace25d7bf0f (diff)
downloadqutebrowser-1c9f93c4a66b8b1035fbba5b683c6592950cb40e.tar.gz
qutebrowser-1c9f93c4a66b8b1035fbba5b683c6592950cb40e.zip
lint: Fix flake8 around key handling
-rw-r--r--qutebrowser/keyinput/basekeyparser.py9
-rw-r--r--qutebrowser/keyinput/keyutils.py9
2 files changed, 12 insertions, 6 deletions
diff --git a/qutebrowser/keyinput/basekeyparser.py b/qutebrowser/keyinput/basekeyparser.py
index 093478e22..467192975 100644
--- a/qutebrowser/keyinput/basekeyparser.py
+++ b/qutebrowser/keyinput/basekeyparser.py
@@ -287,9 +287,8 @@ class BaseKeyParser(QObject):
try:
info = keyutils.KeyInfo.from_event(e)
except keyutils.InvalidKeyError as e:
- # FIXME:qt6 What should we do in this case?
# See https://github.com/qutebrowser/qutebrowser/issues/7047
- log.keyboard.debug("Got invalid key")
+ log.keyboard.debug(f"Got invalid key: {e}")
self.clear_keystring()
return QKeySequence.SequenceMatch.NoMatch
@@ -322,7 +321,11 @@ class BaseKeyParser(QObject):
return result.match_type
self._sequence = result.sequence
+ self._handle_result(info, result)
+ return result.match_type
+ def _handle_result(self, info: keyutils.KeyInfo, result: MatchResult) -> None:
+ """Handle a final MatchResult from handle()."""
if result.match_type == QKeySequence.SequenceMatch.ExactMatch:
assert result.command is not None
self._debug_log("Definitive match for '{}'.".format(
@@ -342,8 +345,6 @@ class BaseKeyParser(QObject):
raise utils.Unreachable("Invalid match value {!r}".format(
result.match_type))
- return result.match_type
-
@config.change_filter('bindings')
def _on_config_changed(self) -> None:
self._read_config()
diff --git a/qutebrowser/keyinput/keyutils.py b/qutebrowser/keyinput/keyutils.py
index 65508b519..e6d6ce08d 100644
--- a/qutebrowser/keyinput/keyutils.py
+++ b/qutebrowser/keyinput/keyutils.py
@@ -47,7 +47,12 @@ from qutebrowser.utils import utils, qtutils, debug
class InvalidKeyError(Exception):
- # WORKAROUND for https://www.riverbankcomputing.com/pipermail/pyqt/2022-April/044607.html
+ """Raised when a key can't be represented by PyQt.
+
+ WORKAROUND for https://www.riverbankcomputing.com/pipermail/pyqt/2022-April/044607.html
+ Should be fixed in PyQt 6.3.1 (or 6.4.0?).
+ """
+
pass
@@ -408,7 +413,7 @@ class KeyInfo:
return cls(key, modifiers)
else:
# QKeyCombination is now guaranteed to be available here
- assert isinstance(combination, QKeyCombination)
+ assert isinstance(combination, QKeyCombination)
try:
key = combination.key()
except ValueError as e: