summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2017-10-11 08:09:55 +0200
committerFlorian Bruhin <git@the-compiler.org>2017-10-11 08:41:23 +0200
commitbdc82bc633a50d937dac483d3f6789ddc1652029 (patch)
tree8679422eb8e28e75a6e194acef40679358de9d68
parent59a1609dd8fab06f28123be65a9d9645837ec8fe (diff)
downloadqutebrowser-bdc82bc633a50d937dac483d3f6789ddc1652029.tar.gz
qutebrowser-bdc82bc633a50d937dac483d3f6789ddc1652029.zip
Fix lint
See https://github.com/PyCQA/pylint/issues/1698
-rw-r--r--.pylintrc6
-rw-r--r--qutebrowser/config/configfiles.py19
-rw-r--r--tests/unit/config/test_configexc.py2
-rw-r--r--tests/unit/config/test_configinit.py2
4 files changed, 18 insertions, 11 deletions
diff --git a/.pylintrc b/.pylintrc
index 39cbf052d..bd988944c 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -36,7 +36,11 @@ disable=no-self-use,
too-many-return-statements,
duplicate-code,
wrong-import-position,
- no-else-return
+ no-else-return,
+ # https://github.com/PyCQA/pylint/issues/1698
+ unsupported-membership-test,
+ unsupported-assignment-operation,
+ unsubscriptable-object
[BASIC]
function-rgx=[a-z_][a-z0-9_]{2,50}$
diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py
index 6439f9688..e1a10848e 100644
--- a/qutebrowser/config/configfiles.py
+++ b/qutebrowser/config/configfiles.py
@@ -162,16 +162,22 @@ class YamlConfig(QObject):
"'global' object is not a dict")
raise configexc.ConfigFileErrors('autoconfig.yml', [desc])
- # Handle unknown/renamed keys
- for name in list(global_obj):
+ self._values = global_obj
+ self._dirty = False
+
+ self._handle_migrations()
+
+ def _handle_migrations(self):
+ """Handle unknown/renamed keys."""
+ for name in list(self._values):
if name in configdata.MIGRATIONS.renamed:
new_name = configdata.MIGRATIONS.renamed[name]
log.config.debug("Renaming {} to {}".format(name, new_name))
- global_obj[new_name] = global_obj[name]
- del global_obj[name]
+ self._values[new_name] = self._values[name]
+ del self._values[name]
elif name in configdata.MIGRATIONS.deleted:
log.config.debug("Removing {}".format(name))
- del global_obj[name]
+ del self._values[name]
elif name in configdata.DATA:
pass
else:
@@ -180,9 +186,6 @@ class YamlConfig(QObject):
"Unknown option {}".format(name))
raise configexc.ConfigFileErrors('autoconfig.yml', [desc])
- self._values = global_obj
- self._dirty = False
-
def unset(self, name):
"""Remove the given option name if it's configured."""
try:
diff --git a/tests/unit/config/test_configexc.py b/tests/unit/config/test_configexc.py
index 2eb44372e..03248731b 100644
--- a/tests/unit/config/test_configexc.py
+++ b/tests/unit/config/test_configexc.py
@@ -45,7 +45,7 @@ def test_no_option_error(deleted, renamed, expected):
def test_no_option_error_clash():
with pytest.raises(AssertionError):
- e = configexc.NoOptionError('opt', deleted=True, renamed='foo')
+ configexc.NoOptionError('opt', deleted=True, renamed='foo')
def test_backend_error():
diff --git a/tests/unit/config/test_configinit.py b/tests/unit/config/test_configinit.py
index 702e39110..cf77d415e 100644
--- a/tests/unit/config/test_configinit.py
+++ b/tests/unit/config/test_configinit.py
@@ -103,7 +103,7 @@ class TestEarlyInit:
else:
assert config.instance._values == {}
- @pytest.mark.parametrize('load_autoconfig', [True, False])
+ @pytest.mark.parametrize('load_autoconfig', [True, False]) # noqa
@pytest.mark.parametrize('config_py', [True, 'error', False])
@pytest.mark.parametrize('invalid_yaml', ['42', 'unknown', 'wrong-type',
False])