From f059bf0b3da0012ba440b96d1869a30c02507fc3 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 28 Jan 2014 19:52:09 +0100 Subject: [PATCH] some pylint fixes --- qutebrowser/app.py | 7 ++++--- qutebrowser/commands/__init__.py | 3 +-- qutebrowser/commands/keys.py | 2 +- qutebrowser/commands/utils.py | 5 +++-- qutebrowser/utils/completion.py | 12 ++++++------ qutebrowser/utils/config.py | 5 +++-- qutebrowser/widgets/completion.py | 2 +- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index d7fbd6191..08e24364c 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -31,7 +31,7 @@ class QuteBrowser(QApplication): # Handle segfaults faulthandler.enable() - args = self.parseopts() + self.parseopts() self.initlog() self.dirs = AppDirs('qutebrowser') @@ -70,6 +70,7 @@ class QuteBrowser(QApplication): def exception_hook(self, exctype, value, traceback): """Try very hard to write open tabs to a file and exit gracefully""" + # pylint: disable=broad-except sys.__excepthook__(exctype, value, traceback) try: for tabidx in range(self.mainwindow.tabs.count()): @@ -152,7 +153,7 @@ class QuteBrowser(QApplication): 'forward': self.mainwindow.tabs.cur_forward, 'print': self.mainwindow.tabs.cur_print, 'scroll': self.mainwindow.tabs.cur_scroll, - 'scroll_perc_y': self.mainwindow.tabs.cur_scroll_percent_x, + 'scroll_perc_x': self.mainwindow.tabs.cur_scroll_percent_x, 'scroll_perc_y': self.mainwindow.tabs.cur_scroll_percent_y, 'undo': self.mainwindow.tabs.undo_close, 'pyeval': self.pyeval, @@ -170,7 +171,7 @@ class QuteBrowser(QApplication): try: r = eval(s) out = repr(r) - except Exception as e: + except Exception as e: # pylint: disable=broad-except out = ': '.join([e.__class__.__name__, str(e)]) # FIXME we probably want some nicer interface to display these about: diff --git a/qutebrowser/commands/__init__.py b/qutebrowser/commands/__init__.py index 2d97fe05d..4aee96ed3 100644 --- a/qutebrowser/commands/__init__.py +++ b/qutebrowser/commands/__init__.py @@ -1,5 +1,3 @@ -from qutebrowser.commands.utils import Command - """All command classes. These are automatically propagated from commands.utils via inspect. @@ -19,6 +17,7 @@ A command class can set the following properties: desc -- Description of the command """ +from qutebrowser.commands.utils import Command class Open(Command): nargs = 1 diff --git a/qutebrowser/commands/keys.py b/qutebrowser/commands/keys.py index 5881cc80c..553c2ba79 100644 --- a/qutebrowser/commands/keys.py +++ b/qutebrowser/commands/keys.py @@ -57,7 +57,7 @@ class KeyParser(QObject): self.keystring = '' return - (countstr, cmdstr_needle) = re.match('^(\d*)(.*)', + (countstr, cmdstr_needle) = re.match(r'^(\d*)(.*)', self.keystring).groups() if not cmdstr_needle: diff --git a/qutebrowser/commands/utils.py b/qutebrowser/commands/utils.py index 43d394059..4428f5937 100644 --- a/qutebrowser/commands/utils.py +++ b/qutebrowser/commands/utils.py @@ -21,7 +21,7 @@ def register_all(): # We do this here to avoid a circular import, since commands.commands # imports Command from this module. import qutebrowser.commands - for (name, cls) in inspect.getmembers( + for (name, cls) in inspect.getmembers( # pylint: disable=unused-variable qutebrowser.commands, (lambda o: inspect.isclass(o) and o.__module__ == 'qutebrowser.commands')): obj = cls() @@ -85,9 +85,10 @@ class CommandParser(QObject): self._run(count=count) class CommandCompletionModel(CompletionModel): + # pylint: disable=abstract-method def __init__(self, parent=None): super().__init__(parent) - assert(cmd_dict) + assert cmd_dict cmdlist = [] for obj in set(cmd_dict.values()): if not obj.hide: diff --git a/qutebrowser/utils/completion.py b/qutebrowser/utils/completion.py index bec71ee24..223d4cb0c 100644 --- a/qutebrowser/utils/completion.py +++ b/qutebrowser/utils/completion.py @@ -1,4 +1,3 @@ -import logging from collections import OrderedDict from PyQt5.QtCore import (QAbstractItemModel, Qt, QModelIndex, QVariant, @@ -12,10 +11,10 @@ class CompletionModel(QAbstractItemModel): self.root = CompletionItem([""] * 2) def removeRows(self, position=0, count=1, parent=QModelIndex()): - node = self.node(parent) - self.beginRemoveRows(parent, position, position + count - 1) - node.childItems.pop(position) - self.endRemoveRows() + node = self.node(parent) + self.beginRemoveRows(parent, position, position + count - 1) + node.children.pop(position) + self.endRemoveRows() def node(self, index): if index.isValid(): @@ -24,6 +23,7 @@ class CompletionModel(QAbstractItemModel): return self.root def columnCount(self, parent=QModelIndex()): + # pylint: disable=unused-argument return self.root.column_count() def data(self, index, role=Qt.DisplayRole): @@ -167,7 +167,7 @@ class CompletionFilterModel(QSortFilterProxyModel): def filterAcceptsRow(self, row, parent): if parent == QModelIndex(): return True - idx = self.sourceModel().index(row, 0, parent); + idx = self.sourceModel().index(row, 0, parent) data = self.sourceModel().data(idx).value() # TODO more sophisticated filtering if not self.pattern: diff --git a/qutebrowser/utils/config.py b/qutebrowser/utils/config.py index 094e21a67..12f9e59d7 100644 --- a/qutebrowser/utils/config.py +++ b/qutebrowser/utils/config.py @@ -3,6 +3,7 @@ import os import logging from configparser import ConfigParser +# pylint: disable=abstract-class-little-used config = None colordict = {} @@ -32,7 +33,8 @@ default_config = { 'colors': { 'completion.fg': '#333333', 'completion.item.bg': 'white', - 'completion.category.bg': 'qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #e4e4e4, stop:1 #dbdbdb)', + 'completion.category.bg': ('qlineargradient(x1:0, y1:0, x2:0, y2:1, ' + 'stop:0 #e4e4e4, stop:1 #dbdbdb)'), 'completion.category.border.top': '#808080', 'completion.category.border.bottom': '#bbbbbb', 'completion.item.selected.fg': '#333333', @@ -67,7 +69,6 @@ def init(confdir): colordict = ColorDict() def get_stylesheet(template): - global colordict return template.strip().format(color=colordict, monospace=MONOSPACE) class ColorDict(dict): diff --git a/qutebrowser/widgets/completion.py b/qutebrowser/widgets/completion.py index 6979e529f..eeb7da2a8 100644 --- a/qutebrowser/widgets/completion.py +++ b/qutebrowser/widgets/completion.py @@ -61,7 +61,7 @@ class CompletionView(QTreeView): self.model.setSourceModel(self.completion_models['command']) self.model.pattern_changed.connect(self.resort) self.setItemDelegate(CompletionItemDelegate()) - self.setStyleSheet(config.get_stylesheet(self._stylesheet) + self.setStyleSheet(config.get_stylesheet(self._stylesheet)) self.expandAll() self.setHeaderHidden(True) self.setIndentation(0)