Fix pylint

This also reverts commit 8df0b063be.
This commit is contained in:
Florian Bruhin 2017-07-04 15:33:58 +02:00
parent 88b878098d
commit cff61fa0bc
38 changed files with 93 additions and 75 deletions

View File

@ -22,7 +22,6 @@
import os import os
import sys import sys
import subprocess import subprocess
import configparser
import functools import functools
import json import json
import shutil import shutil
@ -647,8 +646,8 @@ class Quitter:
"""Quit qutebrowser. """Quit qutebrowser.
Args: Args:
save: When given, save the open windows even if auto_save.session is save: When given, save the open windows even if auto_save.session
turned off. is turned off.
session: The name of the session to save. session: The name of the session to save.
""" """
if session is not None and not save: if session is not None and not save:

View File

@ -33,7 +33,7 @@ import pygments.lexers
import pygments.formatters import pygments.formatters
from qutebrowser.commands import userscripts, cmdexc, cmdutils, runners from qutebrowser.commands import userscripts, cmdexc, cmdutils, runners
from qutebrowser.config import config, configexc, configdata from qutebrowser.config import config, configdata
from qutebrowser.browser import (urlmarks, browsertab, inspector, navigate, from qutebrowser.browser import (urlmarks, browsertab, inspector, navigate,
webelem, downloads) webelem, downloads)
from qutebrowser.keyinput import modeman from qutebrowser.keyinput import modeman

View File

@ -472,10 +472,12 @@ class AbstractDownloadItem(QObject):
position: The color type requested, can be 'fg' or 'bg'. position: The color type requested, can be 'fg' or 'bg'.
""" """
assert position in ["fg", "bg"] assert position in ["fg", "bg"]
# pylint: disable=bad-config-option
start = getattr(config.val.colors.downloads.start, position) start = getattr(config.val.colors.downloads.start, position)
stop = getattr(config.val.colors.downloads.stop, position) stop = getattr(config.val.colors.downloads.stop, position)
system = getattr(config.val.colors.downloads.system, position) system = getattr(config.val.colors.downloads.system, position)
error = getattr(config.val.colors.downloads.error, position) error = getattr(config.val.colors.downloads.error, position)
# pylint: enable=bad-config-option
if self.error_msg is not None: if self.error_msg is not None:
assert not self.successful assert not self.successful
return error return error

View File

@ -83,7 +83,10 @@ def _find_prevnext(prev, elems):
option = 'prev_regexes' if prev else 'next_regexes' option = 'prev_regexes' if prev else 'next_regexes'
if not elems: if not elems:
return None return None
# pylint: disable=bad-config-option
for regex in getattr(config.val.hints, option): for regex in getattr(config.val.hints, option):
# pylint: enable=bad-config-option
log.hints.vdebug("== Checking regex '{}'.".format(regex.pattern)) log.hints.vdebug("== Checking regex '{}'.".format(regex.pattern))
for e in elems: for e in elems:
text = str(e) text = str(e)

View File

@ -249,6 +249,7 @@ class PACFetcher(QObject):
self._manager.setProxy(QNetworkProxy(QNetworkProxy.NoProxy)) self._manager.setProxy(QNetworkProxy(QNetworkProxy.NoProxy))
self._pac = None self._pac = None
self._error_message = None self._error_message = None
self._reply = None
def __eq__(self, other): def __eq__(self, other):
# pylint: disable=protected-access # pylint: disable=protected-access

View File

@ -40,7 +40,8 @@ def custom_headers():
headers[b'DNT'] = dnt headers[b'DNT'] = dnt
headers[b'X-Do-Not-Track'] = dnt headers[b'X-Do-Not-Track'] = dnt
for header, value in config.val.content.headers.custom.items(): conf_headers = config.val.content.headers.custom
for header, value in conf_headers.items():
headers[header.encode('ascii')] = value.encode('ascii') headers[header.encode('ascii')] = value.encode('ascii')
accept_language = config.val.content.headers.accept_language accept_language = config.val.content.headers.accept_language

View File

@ -21,12 +21,11 @@
import mimetypes import mimetypes
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtNetwork import QNetworkReply from PyQt5.QtNetwork import QNetworkReply
from qutebrowser.browser import pdfjs, qutescheme from qutebrowser.browser import pdfjs, qutescheme
from qutebrowser.browser.webkit.network import schemehandler, networkreply from qutebrowser.browser.webkit.network import schemehandler, networkreply
from qutebrowser.utils import jinja, log, message, usertypes, qtutils from qutebrowser.utils import log, usertypes, qtutils
class QuteSchemeHandler(schemehandler.SchemeHandler): class QuteSchemeHandler(schemehandler.SchemeHandler):

View File

@ -27,7 +27,6 @@ import sip
from PyQt5.QtCore import (pyqtSlot, Qt, QEvent, QUrl, QPoint, QTimer, QSizeF, from PyQt5.QtCore import (pyqtSlot, Qt, QEvent, QUrl, QPoint, QTimer, QSizeF,
QSize) QSize)
from PyQt5.QtGui import QKeyEvent from PyQt5.QtGui import QKeyEvent
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebKitWidgets import QWebPage, QWebFrame from PyQt5.QtWebKitWidgets import QWebPage, QWebFrame
from PyQt5.QtWebKit import QWebSettings from PyQt5.QtWebKit import QWebSettings
from PyQt5.QtPrintSupport import QPrinter from PyQt5.QtPrintSupport import QPrinter

View File

@ -25,7 +25,7 @@ from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QUrl
from PyQt5.QtGui import QPalette from PyQt5.QtGui import QPalette
from PyQt5.QtWidgets import QStyleFactory from PyQt5.QtWidgets import QStyleFactory
from PyQt5.QtWebKit import QWebSettings from PyQt5.QtWebKit import QWebSettings
from PyQt5.QtWebKitWidgets import QWebView, QWebPage, QWebFrame from PyQt5.QtWebKitWidgets import QWebView, QWebPage
from qutebrowser.config import config from qutebrowser.config import config
from qutebrowser.keyinput import modeman from qutebrowser.keyinput import modeman

View File

@ -19,6 +19,9 @@
"""CompletionModels for the config.""" """CompletionModels for the config."""
# FIXME:conf
# pylint: disable=no-member
from PyQt5.QtCore import pyqtSlot, Qt from PyQt5.QtCore import pyqtSlot, Qt
from qutebrowser.config import config, configdata from qutebrowser.config import config, configdata

View File

@ -19,6 +19,9 @@
"""Misc. CompletionModels.""" """Misc. CompletionModels."""
# FIXME:conf
# pylint: disable=unused-argument
from PyQt5.QtCore import Qt, QTimer, pyqtSlot from PyQt5.QtCore import Qt, QTimer, pyqtSlot
from qutebrowser.browser import browsertab from qutebrowser.browser import browsertab

View File

@ -20,15 +20,13 @@
"""Configuration storage and config-related utilities.""" """Configuration storage and config-related utilities."""
import copy import copy
import os.path
import contextlib import contextlib
import functools import functools
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, QUrl from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, QUrl
from qutebrowser.config import configdata, configexc, configtypes, configfiles from qutebrowser.config import configdata, configexc, configtypes, configfiles
from qutebrowser.utils import (utils, objreg, message, standarddir, log, from qutebrowser.utils import utils, objreg, message, log, usertypes
usertypes)
from qutebrowser.misc import objects from qutebrowser.misc import objects
from qutebrowser.commands import cmdexc, cmdutils from qutebrowser.commands import cmdexc, cmdutils
@ -279,8 +277,8 @@ class ConfigCommands:
def _print_value(self, option): def _print_value(self, option):
"""Print the value of the given option.""" """Print the value of the given option."""
with self._handle_config_error(): with self._handle_config_error():
val = self._config.get_str(option) value = self._config.get_str(option)
message.info("{} = {}".format(option, val)) message.info("{} = {}".format(option, value))
def _set_next(self, option, values, *, temp): def _set_next(self, option, values, *, temp):
"""Set the next value out of a list of values.""" """Set the next value out of a list of values."""
@ -292,9 +290,9 @@ class ConfigCommands:
# Use the next valid value from values, or the first if the current # Use the next valid value from values, or the first if the current
# value does not appear in the list # value does not appear in the list
val = self._config.get_str(option) old_value = self._config.get_str(option)
try: try:
idx = values.index(str(val)) idx = values.index(str(old_value))
idx = (idx + 1) % len(values) idx = (idx + 1) % len(values)
value = values[idx] value = values[idx]
except ValueError: except ValueError:

View File

@ -27,7 +27,6 @@ DATA: A dict of Option objects after init() has been called.
# FIXME:conf reintroduce interpolation? # FIXME:conf reintroduce interpolation?
import sys import sys
import re
import collections import collections
import functools import functools

View File

@ -170,7 +170,10 @@ class BaseType:
self._basic_str_validation(value) self._basic_str_validation(value)
def _basic_str_validation(self, value): def _basic_str_validation(self, value):
"""Do some basic validation for string values (empty, non-printable chars). """Do some basic validation for string values.
This checks that the value isn't empty and doesn't contain any
unprintable chars.
Arguments: Arguments:
value: The value to check. value: The value to check.
@ -211,9 +214,9 @@ class BaseType:
def from_str(self, value): def from_str(self, value):
"""Get the setting value from a string. """Get the setting value from a string.
By default this invokes to_py() for validation and returns the unaltered By default this invokes to_py() for validation and returns the
value. This means that if to_py() returns a string rather than something unaltered value. This means that if to_py() returns a string rather
more sophisticated, this doesn't need to be implemented. than something more sophisticated, this doesn't need to be implemented.
Args: Args:
value: The original string value. value: The original string value.
@ -256,6 +259,7 @@ class BaseType:
This currently uses asciidoc syntax. This currently uses asciidoc syntax.
""" """
utils.unused(indent) # only needed for Dict/List
if not value: if not value:
return 'empty' return 'empty'
return '+pass:[{}]+'.format(html.escape(self.to_str(value))) return '+pass:[{}]+'.format(html.escape(self.to_str(value)))

View File

@ -23,10 +23,10 @@ import re
import functools import functools
import unicodedata import unicodedata
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject from PyQt5.QtCore import pyqtSignal, QObject
from qutebrowser.config import config from qutebrowser.config import config
from qutebrowser.utils import usertypes, log, utils, objreg from qutebrowser.utils import usertypes, log, utils
class BaseKeyParser(QObject): class BaseKeyParser(QObject):
@ -190,7 +190,8 @@ class BaseKeyParser(QObject):
return self.Match.none return self.Match.none
self._stop_timers() self._stop_timers()
txt = config.val.bindings.key_mappings.get(txt, txt) key_mappings = config.val.bindings.key_mappings
txt = key_mappings.get(txt, txt)
self._keystring += txt self._keystring += txt
count, cmd_input = self._split_count() count, cmd_input = self._split_count()

View File

@ -65,7 +65,8 @@ class Message(QLabel):
raise ValueError("Invalid level {!r}".format(level)) raise ValueError("Invalid level {!r}".format(level))
# We don't bother with set_register_stylesheet here as it's short-lived # We don't bother with set_register_stylesheet here as it's short-lived
# anyways. # anyways.
config.set_register_stylesheet(self, stylesheet=stylesheet, update=False) config.set_register_stylesheet(self, stylesheet=stylesheet,
update=False)
class MessageView(QWidget): class MessageView(QWidget):

View File

@ -176,7 +176,8 @@ class TabbedBrowser(tabwidget.TabWidget):
fields = self.get_tab_fields(idx) fields = self.get_tab_fields(idx)
fields['id'] = self._win_id fields['id'] = self._win_id
title = config.val.window.title_format.format(**fields) title_format = config.val.window.title_format
title = title_format.format(**fields)
self.window().setWindowTitle(title) self.window().setWindowTitle(title)
def _connect_tab_signals(self, tab): def _connect_tab_signals(self, tab):

View File

@ -546,15 +546,15 @@ class TabBar(QTabBar):
def paintEvent(self, _e): def paintEvent(self, _e):
"""Override paintEvent to draw the tabs like we want to.""" """Override paintEvent to draw the tabs like we want to."""
# pylint: disable=bad-config-call
# WORKAROUND for https://bitbucket.org/logilab/astroid/issue/104
p = QStylePainter(self) p = QStylePainter(self)
selected = self.currentIndex() selected = self.currentIndex()
for idx in range(self.count()): for idx in range(self.count()):
tab = QStyleOptionTab() tab = QStyleOptionTab()
self.initStyleOption(tab, idx) self.initStyleOption(tab, idx)
# pylint: disable=bad-config-option
setting = config.val.colors.tabs setting = config.val.colors.tabs
# pylint: enable=bad-config-option
if idx == selected: if idx == selected:
setting = setting.selected setting = setting.selected
setting = setting.odd if idx % 2 else setting.even setting = setting.odd if idx % 2 else setting.even

View File

@ -31,7 +31,7 @@ from PyQt5.QtWidgets import QLabel, QSizePolicy
from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt
from qutebrowser.config import config from qutebrowser.config import config
from qutebrowser.utils import objreg, utils, usertypes from qutebrowser.utils import utils, usertypes
class KeyHintView(QLabel): class KeyHintView(QLabel):

View File

@ -864,6 +864,11 @@ def open_file(filename, cmdline=None):
proc.start_detached(cmd, args) proc.start_detached(cmd, args)
def unused(_arg):
"""Function which does nothing to avoid pylint complaining."""
pass
def expand_windows_drive(path): def expand_windows_drive(path):
r"""Expand a drive-path like E: into E:\. r"""Expand a drive-path like E: into E:\.

View File

@ -40,20 +40,17 @@ class ConfigChecker(checkers.BaseChecker):
name = 'config' name = 'config'
msgs = { msgs = {
'E9998': ('%s is no valid config option.', # flake8: disable=S001 'E9998': ('%s is no valid config option.', # flake8: disable=S001
'bad-config-call', 'bad-config-option',
None),
'E9999': ('old config call', # flake8: disable=S001
'old-config-call',
None), None),
} }
priority = -1 priority = -1
@utils.check_messages('bad-config-call') @utils.check_messages('bad-config-option')
def visit_attribute(self, node): def visit_attribute(self, node):
"""Visit a getattr node.""" """Visit a getattr node."""
# At the end of a config.val.foo.bar chain # At the end of a config.val.foo.bar chain
if not isinstance(node.parent, astroid.Attribute): if not isinstance(node.parent, astroid.Attribute):
# FIXME do some proper check for this... # FIXME:conf do some proper check for this...
node_str = node.as_string() node_str = node.as_string()
prefix = 'config.val.' prefix = 'config.val.'
if node_str.startswith(prefix): if node_str.startswith(prefix):
@ -62,7 +59,7 @@ class ConfigChecker(checkers.BaseChecker):
def _check_config(self, node, name): def _check_config(self, node, name):
"""Check that we're accessing proper config options.""" """Check that we're accessing proper config options."""
if name not in OPTIONS: if name not in OPTIONS:
self.add_message('bad-config-call', node=node, args=name) self.add_message('bad-config-option', node=node, args=name)
def register(linter): def register(linter):

View File

@ -22,7 +22,6 @@
import os import os
import sys import sys
import html
import shutil import shutil
import os.path import os.path
import inspect import inspect

View File

@ -27,4 +27,5 @@ def invoke_with(quteproc):
quteproc.log_summary("Create a new window") quteproc.log_summary("Create a new window")
quteproc.send_ipc([], target_arg='window') quteproc.send_ipc([], target_arg='window')
quteproc.wait_for(category='init', module='app', quteproc.wait_for(category='init', module='app',
function='_open_startpage', message='Opening start pages') function='_open_startpage',
message='Opening start pages')

View File

@ -17,7 +17,5 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>. # along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
import pytest
import pytest_bdd as bdd import pytest_bdd as bdd
bdd.scenarios('keyinput.feature') bdd.scenarios('keyinput.feature')

View File

@ -30,8 +30,7 @@ from PyQt5.QtNetwork import (QNetworkRequest, QAbstractNetworkCache,
from PyQt5.QtWidgets import QCommonStyle, QLineEdit, QWidget, QTabBar from PyQt5.QtWidgets import QCommonStyle, QLineEdit, QWidget, QTabBar
from qutebrowser.browser import browsertab, history from qutebrowser.browser import browsertab, history
from qutebrowser.config import configexc, configdata from qutebrowser.utils import usertypes
from qutebrowser.utils import usertypes, utils
from qutebrowser.mainwindow import mainwindow from qutebrowser.mainwindow import mainwindow

View File

@ -34,24 +34,24 @@ pytestmark = pytest.mark.usefixtures('qapp', 'config_tmpdir')
# TODO See ../utils/test_standarddirutils for OSError and caplog assertion # TODO See ../utils/test_standarddirutils for OSError and caplog assertion
WHITELISTED_HOSTS = ['qutebrowser.org', 'mediumhost.io'] WHITELISTED_HOSTS = ('qutebrowser.org', 'mediumhost.io')
BLOCKLIST_HOSTS = ['localhost', BLOCKLIST_HOSTS = ('localhost',
'mediumhost.io', 'mediumhost.io',
'malware.badhost.org', 'malware.badhost.org',
'4-verybadhost.com', '4-verybadhost.com',
'ads.worsthostever.net'] 'ads.worsthostever.net')
CLEAN_HOSTS = ['goodhost.gov', 'verygoodhost.com'] CLEAN_HOSTS = ('goodhost.gov', 'verygoodhost.com')
URLS_TO_CHECK = ['http://localhost', URLS_TO_CHECK = ('http://localhost',
'http://mediumhost.io', 'http://mediumhost.io',
'ftp://malware.badhost.org', 'ftp://malware.badhost.org',
'http://4-verybadhost.com', 'http://4-verybadhost.com',
'http://ads.worsthostever.net', 'http://ads.worsthostever.net',
'http://goodhost.gov', 'http://goodhost.gov',
'ftp://verygoodhost.com', 'ftp://verygoodhost.com',
'http://qutebrowser.org'] 'http://qutebrowser.org')
class BaseDirStub: class BaseDirStub:
@ -374,7 +374,7 @@ def test_blocking_with_whitelist(config_stub, basedir, download_stub,
line_format='one_per_line') line_format='one_per_line')
config_stub.val.content.host_blocking.lists = [blocklist] config_stub.val.content.host_blocking.lists = [blocklist]
config_stub.val.content.host_blocking.enabled = True config_stub.val.content.host_blocking.enabled = True
config_stub.val.content.host_blocking.whitelist = WHITELISTED_HOSTS config_stub.val.content.host_blocking.whitelist = list(WHITELISTED_HOSTS)
host_blocker = adblock.HostBlocker() host_blocker = adblock.HostBlocker()
host_blocker.read_hosts() host_blocker.read_hosts()

View File

@ -42,7 +42,8 @@ class TestCommandParser:
with pytest.raises(cmdexc.NoSuchCommandError): with pytest.raises(cmdexc.NoSuchCommandError):
parser.parse_all(cmdline_test.cmd, aliases=False) parser.parse_all(cmdline_test.cmd, aliases=False)
def test_parse_all_with_alias(self, cmdline_test, monkeypatch, config_stub): def test_parse_all_with_alias(self, cmdline_test, monkeypatch,
config_stub):
if not cmdline_test.cmd: if not cmdline_test.cmd:
pytest.skip("Empty command") pytest.skip("Empty command")

View File

@ -30,7 +30,8 @@ from qutebrowser.utils import usertypes
from qutebrowser.commands import command, cmdutils from qutebrowser.commands import command, cmdutils
pytestmark = pytest.mark.skip("FIXME:conf reintroduce after new completion is in") pytestmark = pytest.mark.skip("FIXME:conf reintroduce after new completion "
"is in")
class FakeCompletionModel(QStandardItemModel): class FakeCompletionModel(QStandardItemModel):

View File

@ -22,7 +22,7 @@
import unittest.mock import unittest.mock
import pytest import pytest
from PyQt5.QtGui import QStandardItem, QColor from PyQt5.QtGui import QStandardItem
from qutebrowser.completion import completionwidget from qutebrowser.completion import completionwidget
from qutebrowser.completion.models import base, sortfilter from qutebrowser.completion.models import base, sortfilter

View File

@ -17,6 +17,9 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>. # along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
# FIXME:conf
# pylint: disable=undefined-variable
"""Tests for completion models.""" """Tests for completion models."""
import collections import collections
@ -31,7 +34,8 @@ from qutebrowser.completion.models import (miscmodels, urlmodel, configmodel,
from qutebrowser.browser import history from qutebrowser.browser import history
pytestmark = pytest.mark.skip("FIXME:conf reintroduce after new completion is in") pytestmark = pytest.mark.skip("FIXME:conf reintroduce after new completion "
"is in")
def _check_completions(model, expected): def _check_completions(model, expected):

View File

@ -26,7 +26,7 @@ from PyQt5.QtCore import QObject, QUrl
from PyQt5.QtGui import QColor from PyQt5.QtGui import QColor
from qutebrowser.commands import cmdexc from qutebrowser.commands import cmdexc
from qutebrowser.config import config, configdata, configexc, configfiles from qutebrowser.config import config, configdata, configexc
from qutebrowser.utils import objreg, usertypes from qutebrowser.utils import objreg, usertypes
from qutebrowser.misc import objects from qutebrowser.misc import objects
@ -83,7 +83,7 @@ class TestChangeFilter:
was_called = True was_called = True
foo = Foo() foo = Foo()
foo.meth(changed) foo.meth(changed) # pylint: disable=too-many-function-args
else: else:
@ -92,7 +92,7 @@ class TestChangeFilter:
nonlocal was_called nonlocal was_called
was_called = True was_called = True
func(changed) func(changed) # pylint: disable=too-many-function-args
assert was_called == matches assert was_called == matches
@ -127,7 +127,8 @@ class TestKeyConfig:
({'a': None}, {'b': 'message-info bar'}), ({'a': None}, {'b': 'message-info bar'}),
# Additional binding # Additional binding
({'c': 'message-info baz'}, ({'c': 'message-info baz'},
{'a': 'message-info foo', 'b': 'message-info bar', 'c': 'message-info baz'}), {'a': 'message-info foo', 'b': 'message-info bar',
'c': 'message-info baz'}),
# Unbinding unknown key # Unbinding unknown key
({'x': None}, {'a': 'message-info foo', 'b': 'message-info bar'}), ({'x': None}, {'a': 'message-info foo', 'b': 'message-info bar'}),
]) ])
@ -638,8 +639,9 @@ class TestConfig:
When we get a mutable object from the config, some invariants should be When we get a mutable object from the config, some invariants should be
true: true:
- The object we get from the config is always a copy, i.e. mutating it - The object we get from the config is always a copy, i.e. mutating
doesn't change the internal value (or default) stored in the config. it doesn't change the internal value (or default) stored in the
config.
- If we mutate the object (mutated=True) and the config watches for - If we mutate the object (mutated=True) and the config watches for
mutables (mutable=True), it should notice that the object changed. mutables (mutable=True), it should notice that the object changed.
- With mutable=False, we should always get the old object back. - With mutable=False, we should always get the old object back.
@ -760,7 +762,7 @@ class TestContainer:
def test_getattr_invalid_private(self, container): def test_getattr_invalid_private(self, container):
"""Make sure an invalid _attribute doesn't try getting a container.""" """Make sure an invalid _attribute doesn't try getting a container."""
with pytest.raises(AttributeError): with pytest.raises(AttributeError):
container._foo container._foo # pylint: disable=pointless-statement
def test_getattr_prefix(self, container): def test_getattr_prefix(self, container):
new_container = container.tabs new_container = container.tabs
@ -773,7 +775,7 @@ class TestContainer:
def test_getattr_invalid(self, container): def test_getattr_invalid(self, container):
with pytest.raises(configexc.NoOptionError) as excinfo: with pytest.raises(configexc.NoOptionError) as excinfo:
container.tabs.foobar container.tabs.foobar # pylint: disable=pointless-statement
assert excinfo.value.option == 'tabs.foobar' assert excinfo.value.option == 'tabs.foobar'
def test_setattr_option(self, config_stub, container): def test_setattr_option(self, config_stub, container):

View File

@ -24,7 +24,7 @@ import yaml
import pytest import pytest
# To run cmdutils.register decorators # To run cmdutils.register decorators
from qutebrowser import app from qutebrowser import app # pylint: disable=unused-import
from qutebrowser.config import configdata, configtypes from qutebrowser.config import configdata, configtypes
from qutebrowser.utils import usertypes from qutebrowser.utils import usertypes

View File

@ -44,7 +44,8 @@ def test_state_config(fake_save_manager, data_tmpdir,
if insert: if insert:
state['general']['newval'] = '23' state['general']['newval'] = '23'
if 'foobar' in (old_data or ''): # WORKAROUND for https://github.com/PyCQA/pylint/issues/574
if 'foobar' in (old_data or ''): # pylint: disable=superfluous-parens
assert state['general']['foobar'] == '42' assert state['general']['foobar'] == '42'
state._save() state._save()
@ -81,7 +82,8 @@ def test_yaml_config(fake_save_manager, config_tmpdir, old_config, insert):
else: else:
assert lines[3] == 'global:' assert lines[3] == 'global:'
if 'magenta' in (old_config or ''): # WORKAROUND for https://github.com/PyCQA/pylint/issues/574
if 'magenta' in (old_config or ''): # pylint: disable=superfluous-parens
assert ' colors.hints.fg: magenta' in lines assert ' colors.hints.fg: magenta' in lines
if insert: if insert:
assert ' tabs.show: never' in lines assert ' tabs.show: never' in lines

View File

@ -19,8 +19,6 @@
"""Tests for qutebrowser.config.configtypes.""" """Tests for qutebrowser.config.configtypes."""
import re import re
import os
import sys
import json import json
import math import math
import collections import collections
@ -187,7 +185,7 @@ class TestAll:
"""Various tests which apply to all available config types.""" """Various tests which apply to all available config types."""
def gen_classes(): def gen_classes(): # pylint: disable=no-method-argument
"""Yield all configtypes classes to test. """Yield all configtypes classes to test.
Not a method as it's used in decorators. Not a method as it's used in decorators.

View File

@ -19,12 +19,8 @@
"""pytest fixtures for tests.keyinput.""" """pytest fixtures for tests.keyinput."""
from unittest import mock
import pytest import pytest
from qutebrowser.utils import objreg
BINDINGS = {'prompt': {'<Ctrl-a>': 'message-info ctrla', BINDINGS = {'prompt': {'<Ctrl-a>': 'message-info ctrla',
'a': 'message-info a', 'a': 'message-info a',

View File

@ -21,11 +21,9 @@
import pytest import pytest
from PyQt5.QtGui import QIcon, QPixmap, QFont, QColor from PyQt5.QtGui import QIcon, QPixmap
from PyQt5.QtCore import Qt
from qutebrowser.mainwindow import tabwidget from qutebrowser.mainwindow import tabwidget
from qutebrowser.config import configtypes
from qutebrowser.utils import usertypes from qutebrowser.utils import usertypes

View File

@ -19,7 +19,6 @@
"""Test the keyhint widget.""" """Test the keyhint widget."""
from collections import OrderedDict
import pytest import pytest
from qutebrowser.misc.keyhintwidget import KeyHintView from qutebrowser.misc.keyhintwidget import KeyHintView

View File

@ -922,6 +922,10 @@ class TestOpenFile:
m.assert_called_with(QUrl('file:///foo/bar')) m.assert_called_with(QUrl('file:///foo/bar'))
def test_unused():
utils.unused(None)
@pytest.mark.parametrize('path, expected', [ @pytest.mark.parametrize('path, expected', [
('E:', 'E:\\'), ('E:', 'E:\\'),
('e:', 'e:\\'), ('e:', 'e:\\'),