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
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:

View File

@ -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

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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):

View File

@ -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)