Fix lint
This commit is contained in:
parent
58b7599152
commit
d8bfe23c0d
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
"""Our own QKeySequence-like class and related utilities."""
|
"""Our own QKeySequence-like class and related utilities."""
|
||||||
|
|
||||||
import collections
|
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
import attr
|
import attr
|
||||||
@ -46,8 +45,8 @@ def is_printable(key):
|
|||||||
def is_modifier_key(key):
|
def is_modifier_key(key):
|
||||||
"""Test whether the given key is a modifier.
|
"""Test whether the given key is a modifier.
|
||||||
|
|
||||||
This only considers keys which are part of Qt::KeyboardModifiers, i.e. which
|
This only considers keys which are part of Qt::KeyboardModifiers, i.e.
|
||||||
would interrupt a key chain like "yY" when handled.
|
which would interrupt a key chain like "yY" when handled.
|
||||||
"""
|
"""
|
||||||
return key in _MODIFIER_MAP
|
return key in _MODIFIER_MAP
|
||||||
|
|
||||||
@ -363,14 +362,15 @@ class KeySequence:
|
|||||||
def matches(self, other):
|
def matches(self, other):
|
||||||
"""Check whether the given KeySequence matches with this one.
|
"""Check whether the given KeySequence matches with this one.
|
||||||
|
|
||||||
We store multiple QKeySequences with <= 4 keys each, so we need to match
|
We store multiple QKeySequences with <= 4 keys each, so we need to
|
||||||
those pair-wise, and account for an unequal amount of sequences as well.
|
match those pair-wise, and account for an unequal amount of sequences
|
||||||
|
as well.
|
||||||
"""
|
"""
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
|
|
||||||
if len(self._sequences) > len(other._sequences):
|
if len(self._sequences) > len(other._sequences):
|
||||||
# If we entered more sequences than there are in the config, there's
|
# If we entered more sequences than there are in the config,
|
||||||
# no way there can be a match.
|
# there's no way there can be a match.
|
||||||
return QKeySequence.NoMatch
|
return QKeySequence.NoMatch
|
||||||
|
|
||||||
for entered, configured in zip(self._sequences, other._sequences):
|
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
|
# PartialMatch, as more keypresses can still follow and new sequences
|
||||||
# will appear which we didn't check above.
|
# will appear which we didn't check above.
|
||||||
#
|
#
|
||||||
# If there's the same amount of sequences configured and entered, that's
|
# If there's the same amount of sequences configured and entered,
|
||||||
# an EqualMatch.
|
# that's an EqualMatch.
|
||||||
if len(self._sequences) == len(other._sequences):
|
if len(self._sequences) == len(other._sequences):
|
||||||
return QKeySequence.ExactMatch
|
return QKeySequence.ExactMatch
|
||||||
elif len(self._sequences) < len(other._sequences):
|
elif len(self._sequences) < len(other._sequences):
|
||||||
return QKeySequence.PartialMatch
|
return QKeySequence.PartialMatch
|
||||||
else: # pragma: no cover
|
else:
|
||||||
assert False, (self, other)
|
raise utils.Unreachable("self={!r} other={!r}".format(self, other))
|
||||||
|
|
||||||
def append_event(self, ev):
|
def append_event(self, ev):
|
||||||
"""Create a new KeySequence object with the given QKeyEvent added.
|
"""Create a new KeySequence object with the given QKeyEvent added.
|
||||||
|
@ -25,7 +25,6 @@ from PyQt5.QtGui import QKeyEvent, QKeySequence
|
|||||||
from PyQt5.QtWidgets import QWidget
|
from PyQt5.QtWidgets import QWidget
|
||||||
|
|
||||||
from tests.unit.keyinput import key_data
|
from tests.unit.keyinput import key_data
|
||||||
from qutebrowser.utils import utils
|
|
||||||
from qutebrowser.keyinput import keyutils
|
from qutebrowser.keyinput import keyutils
|
||||||
|
|
||||||
|
|
||||||
@ -348,7 +347,7 @@ class TestKeySequence:
|
|||||||
('<Control-x>', keyutils.KeySequence(Qt.ControlModifier | Qt.Key_X)),
|
('<Control-x>', keyutils.KeySequence(Qt.ControlModifier | Qt.Key_X)),
|
||||||
('<Meta-x>', keyutils.KeySequence(Qt.MetaModifier | Qt.Key_X)),
|
('<Meta-x>', keyutils.KeySequence(Qt.MetaModifier | Qt.Key_X)),
|
||||||
('<Ctrl-Alt-y>',
|
('<Ctrl-Alt-y>',
|
||||||
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.Key_X)),
|
||||||
('X', keyutils.KeySequence(Qt.ShiftModifier | Qt.Key_X)),
|
('X', keyutils.KeySequence(Qt.ShiftModifier | Qt.Key_X)),
|
||||||
('<Escape>', keyutils.KeySequence(Qt.Key_Escape)),
|
('<Escape>', keyutils.KeySequence(Qt.Key_Escape)),
|
||||||
|
Loading…
Reference in New Issue
Block a user