some pylint fixes

This commit is contained in:
Florian Bruhin 2014-01-28 19:52:09 +01:00
parent cf1d0b616b
commit f059bf0b3d
7 changed files with 19 additions and 17 deletions

View File

@ -31,7 +31,7 @@ class QuteBrowser(QApplication):
# Handle segfaults # Handle segfaults
faulthandler.enable() faulthandler.enable()
args = self.parseopts() self.parseopts()
self.initlog() self.initlog()
self.dirs = AppDirs('qutebrowser') self.dirs = AppDirs('qutebrowser')
@ -70,6 +70,7 @@ class QuteBrowser(QApplication):
def exception_hook(self, exctype, value, traceback): def exception_hook(self, exctype, value, traceback):
"""Try very hard to write open tabs to a file and exit gracefully""" """Try very hard to write open tabs to a file and exit gracefully"""
# pylint: disable=broad-except
sys.__excepthook__(exctype, value, traceback) sys.__excepthook__(exctype, value, traceback)
try: try:
for tabidx in range(self.mainwindow.tabs.count()): for tabidx in range(self.mainwindow.tabs.count()):
@ -152,7 +153,7 @@ class QuteBrowser(QApplication):
'forward': self.mainwindow.tabs.cur_forward, 'forward': self.mainwindow.tabs.cur_forward,
'print': self.mainwindow.tabs.cur_print, 'print': self.mainwindow.tabs.cur_print,
'scroll': self.mainwindow.tabs.cur_scroll, '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, 'scroll_perc_y': self.mainwindow.tabs.cur_scroll_percent_y,
'undo': self.mainwindow.tabs.undo_close, 'undo': self.mainwindow.tabs.undo_close,
'pyeval': self.pyeval, 'pyeval': self.pyeval,
@ -170,7 +171,7 @@ class QuteBrowser(QApplication):
try: try:
r = eval(s) r = eval(s)
out = repr(r) out = repr(r)
except Exception as e: except Exception as e: # pylint: disable=broad-except
out = ': '.join([e.__class__.__name__, str(e)]) out = ': '.join([e.__class__.__name__, str(e)])
# FIXME we probably want some nicer interface to display these about: # FIXME we probably want some nicer interface to display these about:

View File

@ -1,5 +1,3 @@
from qutebrowser.commands.utils import Command
"""All command classes. These are automatically propagated from commands.utils """All command classes. These are automatically propagated from commands.utils
via inspect. via inspect.
@ -19,6 +17,7 @@ A command class can set the following properties:
desc -- Description of the command desc -- Description of the command
""" """
from qutebrowser.commands.utils import Command
class Open(Command): class Open(Command):
nargs = 1 nargs = 1

View File

@ -57,7 +57,7 @@ class KeyParser(QObject):
self.keystring = '' self.keystring = ''
return return
(countstr, cmdstr_needle) = re.match('^(\d*)(.*)', (countstr, cmdstr_needle) = re.match(r'^(\d*)(.*)',
self.keystring).groups() self.keystring).groups()
if not cmdstr_needle: if not cmdstr_needle:

View File

@ -21,7 +21,7 @@ def register_all():
# We do this here to avoid a circular import, since commands.commands # We do this here to avoid a circular import, since commands.commands
# imports Command from this module. # imports Command from this module.
import qutebrowser.commands 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 qutebrowser.commands, (lambda o: inspect.isclass(o) and
o.__module__ == 'qutebrowser.commands')): o.__module__ == 'qutebrowser.commands')):
obj = cls() obj = cls()
@ -85,9 +85,10 @@ class CommandParser(QObject):
self._run(count=count) self._run(count=count)
class CommandCompletionModel(CompletionModel): class CommandCompletionModel(CompletionModel):
# pylint: disable=abstract-method
def __init__(self, parent=None): def __init__(self, parent=None):
super().__init__(parent) super().__init__(parent)
assert(cmd_dict) assert cmd_dict
cmdlist = [] cmdlist = []
for obj in set(cmd_dict.values()): for obj in set(cmd_dict.values()):
if not obj.hide: if not obj.hide:

View File

@ -1,4 +1,3 @@
import logging
from collections import OrderedDict from collections import OrderedDict
from PyQt5.QtCore import (QAbstractItemModel, Qt, QModelIndex, QVariant, from PyQt5.QtCore import (QAbstractItemModel, Qt, QModelIndex, QVariant,
@ -14,7 +13,7 @@ class CompletionModel(QAbstractItemModel):
def removeRows(self, position=0, count=1, parent=QModelIndex()): def removeRows(self, position=0, count=1, parent=QModelIndex()):
node = self.node(parent) node = self.node(parent)
self.beginRemoveRows(parent, position, position + count - 1) self.beginRemoveRows(parent, position, position + count - 1)
node.childItems.pop(position) node.children.pop(position)
self.endRemoveRows() self.endRemoveRows()
def node(self, index): def node(self, index):
@ -24,6 +23,7 @@ class CompletionModel(QAbstractItemModel):
return self.root return self.root
def columnCount(self, parent=QModelIndex()): def columnCount(self, parent=QModelIndex()):
# pylint: disable=unused-argument
return self.root.column_count() return self.root.column_count()
def data(self, index, role=Qt.DisplayRole): def data(self, index, role=Qt.DisplayRole):
@ -167,7 +167,7 @@ class CompletionFilterModel(QSortFilterProxyModel):
def filterAcceptsRow(self, row, parent): def filterAcceptsRow(self, row, parent):
if parent == QModelIndex(): if parent == QModelIndex():
return True return True
idx = self.sourceModel().index(row, 0, parent); idx = self.sourceModel().index(row, 0, parent)
data = self.sourceModel().data(idx).value() data = self.sourceModel().data(idx).value()
# TODO more sophisticated filtering # TODO more sophisticated filtering
if not self.pattern: if not self.pattern:

View File

@ -3,6 +3,7 @@ import os
import logging import logging
from configparser import ConfigParser from configparser import ConfigParser
# pylint: disable=abstract-class-little-used
config = None config = None
colordict = {} colordict = {}
@ -32,7 +33,8 @@ default_config = {
'colors': { 'colors': {
'completion.fg': '#333333', 'completion.fg': '#333333',
'completion.item.bg': 'white', '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.top': '#808080',
'completion.category.border.bottom': '#bbbbbb', 'completion.category.border.bottom': '#bbbbbb',
'completion.item.selected.fg': '#333333', 'completion.item.selected.fg': '#333333',
@ -67,7 +69,6 @@ def init(confdir):
colordict = ColorDict() colordict = ColorDict()
def get_stylesheet(template): def get_stylesheet(template):
global colordict
return template.strip().format(color=colordict, monospace=MONOSPACE) return template.strip().format(color=colordict, monospace=MONOSPACE)
class ColorDict(dict): class ColorDict(dict):

View File

@ -61,7 +61,7 @@ class CompletionView(QTreeView):
self.model.setSourceModel(self.completion_models['command']) self.model.setSourceModel(self.completion_models['command'])
self.model.pattern_changed.connect(self.resort) self.model.pattern_changed.connect(self.resort)
self.setItemDelegate(CompletionItemDelegate()) self.setItemDelegate(CompletionItemDelegate())
self.setStyleSheet(config.get_stylesheet(self._stylesheet) self.setStyleSheet(config.get_stylesheet(self._stylesheet))
self.expandAll() self.expandAll()
self.setHeaderHidden(True) self.setHeaderHidden(True)
self.setIndentation(0) self.setIndentation(0)