diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py index c2f839c22..5d00d2987 100644 --- a/qutebrowser/config/configfiles.py +++ b/qutebrowser/config/configfiles.py @@ -54,7 +54,13 @@ class StateConfig(configparser.ConfigParser): class YamlConfig: - """A config stored on disk as YAML file.""" + """A config stored on disk as YAML file. + + Class attributes: + VERSION: The current version number of the config file. + """ + + VERSION = 1 def __init__(self): save_manager = objreg.get('save-manager') @@ -64,7 +70,7 @@ class YamlConfig: def _save(self): """Save the changed settings to the YAML file.""" - data = {'global': self.values} + data = {'config_version': self.VERSION, 'global': self.values} with qtutils.savefile_open(self._filename) as f: f.write(textwrap.dedent(""" # DO NOT edit this file by hand, qutebrowser will overwrite it. diff --git a/tests/unit/config/test_configfiles.py b/tests/unit/config/test_configfiles.py index cb430580c..07b623fa3 100644 --- a/tests/unit/config/test_configfiles.py +++ b/tests/unit/config/test_configfiles.py @@ -77,11 +77,12 @@ def test_yaml_config(fake_save_manager, config_tmpdir, old_config, insert): print(lines) assert lines[0].startswith('# DO NOT edit this file by hand,') + assert 'config_version: {}'.format(yaml.VERSION) in lines if old_config is None and not insert: - assert lines[3] == 'global: {}' + assert 'global: {}' in lines else: - assert lines[3] == 'global:' + assert 'global:' in lines # WORKAROUND for https://github.com/PyCQA/pylint/issues/574 if 'magenta' in (old_config or ''): # pylint: disable=superfluous-parens