parent
59a1609dd8
commit
bdc82bc633
@ -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}$
|
||||
|
@ -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:
|
||||
|
@ -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():
|
||||
|
@ -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])
|
||||
|
Loading…
Reference in New Issue
Block a user