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