From c7b830d69dbc6da443ba4a21c077a3b781bdeba0 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Tue, 12 Apr 2016 22:00:29 -0400 Subject: [PATCH] Fix up mistakes caught by pylint. --- qutebrowser/browser/commands.py | 21 +++++++++++---------- qutebrowser/keyinput/modeparsers.py | 9 +++++---- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 338c8cb13..4543448b7 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1890,7 +1890,7 @@ class CommandDispatcher: @cmdutils.register(instance='command-dispatcher', scope='window') def set_mark(self, key): - """Set a mark at the current scroll position in the current tab + """Set a mark at the current scroll position in the current tab. Args: key: mark identifier; capital indicates a global mark @@ -1911,13 +1911,13 @@ class CommandDispatcher: @cmdutils.register(instance='command-dispatcher', scope='window') def jump_mark(self, key): - """Jump to the mark named by `key` + """Jump to the mark named by `key`. Args: key: mark identifier; capital indicates a global mark """ # consider urls that differ only in fragment to be identical - cur_url = self._current_url().adjusted(QUrl.RemoveFragment) + urlkey = self._current_url().adjusted(QUrl.RemoveFragment) if key.isupper() and key in self._global_marks: # y is a pixel position relative to the top of the page @@ -1930,12 +1930,12 @@ class CommandDispatcher: self.openurl(url.toString()) self._tabbed_browser.cur_load_finished.connect(callback) - elif cur_url in self._local_marks and key in self._local_marks[cur_url]: - y = self._local_marks[cur_url][key] + elif urlkey in self._local_marks and key in self._local_marks[urlkey]: + y = self._local_marks[urlkey][key] # save the pre-jump position in the special ' mark - # this has to happen after we read the mark, otherwise jump_mark "'" - # would just jump to the current position every time + # this has to happen after we read the mark, otherwise jump_mark + # "'" would just jump to the current position every time self.set_mark("'") self._scroll_px_absolute(y) @@ -1943,10 +1943,11 @@ class CommandDispatcher: message.error(self._win_id, "Mark {} is not set".format(key)) def _current_y_px(self): - """Return the current y scroll position in pixels from the top""" - return self._current_widget().page().currentFrame().scrollPosition().y() + """Return the current y scroll position in pixels from the top.""" + frame = self._current_widget().page().currentFrame() + return frame.scrollPosition().y() def _scroll_px_absolute(self, y): - """Scroll to the position y pixels from the top of the page""" + """Scroll to the position y pixels from the top of the page.""" self.scroll('top') self.scroll_px(0, y) diff --git a/qutebrowser/keyinput/modeparsers.py b/qutebrowser/keyinput/modeparsers.py index 73abf2110..2a6fdff95 100644 --- a/qutebrowser/keyinput/modeparsers.py +++ b/qutebrowser/keyinput/modeparsers.py @@ -25,7 +25,7 @@ Module attributes: from PyQt5.QtCore import pyqtSlot, Qt -from qutebrowser.utils import utils, message +from qutebrowser.utils import message from qutebrowser.config import config from qutebrowser.keyinput import keyparser, modeman from qutebrowser.utils import usertypes, log, objreg, utils @@ -231,6 +231,7 @@ class CaretKeyParser(keyparser.CommandKeyParser): supports_chains=True) self.read_config('caret') + class MarkKeyParser(keyparser.CommandKeyParser): """KeyParser for set_mark and jump_mark mode. @@ -245,7 +246,7 @@ class MarkKeyParser(keyparser.CommandKeyParser): self._mode = mode def handle(self, e): - """Override handle to always match the next key and create a mark + """Override handle to always match the next key and create a mark. Args: e: the KeyPressEvent from Qt. @@ -256,7 +257,7 @@ class MarkKeyParser(keyparser.CommandKeyParser): if utils.keyevent_to_string(e) is None: # this is a modifier key, let it pass and keep going - return True; + return True if not e.text().isalpha() and e.text() != "'": # only valid mark names are [a-zA-Z'] @@ -268,7 +269,7 @@ class MarkKeyParser(keyparser.CommandKeyParser): elif self._mode == usertypes.KeyMode.jump_mark: self._commandrunner.run('jump-mark "{}"'.format(e.text())) else: - raise ValueError("{} is not a valid mark mode".format(mode)) + raise ValueError("{} is not a valid mark mode".format(self._mode)) modeman.leave(self._win_id, self._mode, "valid mark key")