From d8bfe23c0dfabf84ddafba3175b0e07cde75fec6 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 4 Mar 2018 19:43:29 +0100 Subject: [PATCH] Fix lint --- qutebrowser/keyinput/keyutils.py | 22 +++++++++++----------- tests/unit/keyinput/test_keyutils.py | 3 +-- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/qutebrowser/keyinput/keyutils.py b/qutebrowser/keyinput/keyutils.py index 2da32349a..dd2668569 100644 --- a/qutebrowser/keyinput/keyutils.py +++ b/qutebrowser/keyinput/keyutils.py @@ -19,7 +19,6 @@ """Our own QKeySequence-like class and related utilities.""" -import collections import itertools import attr @@ -46,8 +45,8 @@ def is_printable(key): def is_modifier_key(key): """Test whether the given key is a modifier. - This only considers keys which are part of Qt::KeyboardModifiers, i.e. which - would interrupt a key chain like "yY" when handled. + This only considers keys which are part of Qt::KeyboardModifiers, i.e. + which would interrupt a key chain like "yY" when handled. """ return key in _MODIFIER_MAP @@ -363,14 +362,15 @@ class KeySequence: def matches(self, other): """Check whether the given KeySequence matches with this one. - We store multiple QKeySequences with <= 4 keys each, so we need to match - those pair-wise, and account for an unequal amount of sequences as well. + We store multiple QKeySequences with <= 4 keys each, so we need to + match those pair-wise, and account for an unequal amount of sequences + as well. """ # pylint: disable=protected-access if len(self._sequences) > len(other._sequences): - # If we entered more sequences than there are in the config, there's - # no way there can be a match. + # If we entered more sequences than there are in the config, + # there's no way there can be a match. return QKeySequence.NoMatch for entered, configured in zip(self._sequences, other._sequences): @@ -385,14 +385,14 @@ class KeySequence: # PartialMatch, as more keypresses can still follow and new sequences # will appear which we didn't check above. # - # If there's the same amount of sequences configured and entered, that's - # an EqualMatch. + # If there's the same amount of sequences configured and entered, + # that's an EqualMatch. if len(self._sequences) == len(other._sequences): return QKeySequence.ExactMatch elif len(self._sequences) < len(other._sequences): return QKeySequence.PartialMatch - else: # pragma: no cover - assert False, (self, other) + else: + raise utils.Unreachable("self={!r} other={!r}".format(self, other)) def append_event(self, ev): """Create a new KeySequence object with the given QKeyEvent added. diff --git a/tests/unit/keyinput/test_keyutils.py b/tests/unit/keyinput/test_keyutils.py index 3f03f883d..a1e078521 100644 --- a/tests/unit/keyinput/test_keyutils.py +++ b/tests/unit/keyinput/test_keyutils.py @@ -25,7 +25,6 @@ from PyQt5.QtGui import QKeyEvent, QKeySequence from PyQt5.QtWidgets import QWidget from tests.unit.keyinput import key_data -from qutebrowser.utils import utils from qutebrowser.keyinput import keyutils @@ -348,7 +347,7 @@ class TestKeySequence: ('', keyutils.KeySequence(Qt.ControlModifier | Qt.Key_X)), ('', keyutils.KeySequence(Qt.MetaModifier | Qt.Key_X)), ('', - keyutils.KeySequence(Qt.ControlModifier | Qt.AltModifier | Qt.Key_Y)), + keyutils.KeySequence(Qt.ControlModifier | Qt.AltModifier | Qt.Key_Y)), ('x', keyutils.KeySequence(Qt.Key_X)), ('X', keyutils.KeySequence(Qt.ShiftModifier | Qt.Key_X)), ('', keyutils.KeySequence(Qt.Key_Escape)),