Remove null values from configuration file. - #32
Conversation
Automatically generated configuration files (obtained by seeding a
repository without a provided configuration file) contain explicit null
values for all settings that do not have a default value and do not have
been explicitly set on the command line.
Such values (i) may cause problems downstream of parsing the
configuration, and (ii) needlessly pollute the configuration file.
We take care of both problems by
* adding a `purge_null_values` method to explicitly clean a dictionary
of any null values;
* using that new method in two occasions:
* when saving the configuration (so that an automatically generated
or updated file never contains null values in the first place);
* after parsing the configuration and before trying to update it (in
case a file would still somehow contain null values).
closes #31
matentzn
left a comment
There was a problem hiding this comment.
Nice, two optional thoughts
Amend the `purge_null_values` method so that it enters lists and purge any null values in any dict that may be contained (directly or indirectly) in a list item.
matentzn
left a comment
There was a problem hiding this comment.
One thing you should contemplate before merging, but I leave this up to your judgment:
null means "use the default" everywhere, and for a few options the default isn't empty. Concretely, a config with
ci:
workflows:gives you ci = ['github_actions'] and workflows = ['docs', 'qc']
Since this works:
ci: []
workflows: []I am fine to say: lets deal with this with docs; Your judgment.
matentzn
left a comment
There was a problem hiding this comment.
Sorry meant to approve with last comment
Actually such a config gives an error (just tested with ODK 1.6.1): So since using empty values (either implicitly, as in Without this PR:
With this PR:
|
Automatically generated configuration files (obtained by seeding a repository without a provided configuration file) contain explicit null values for all settings that do not have a default value and do not have been explicitly set on the command line.
Such values (i) may cause problems downstream of parsing the configuration, and (ii) needlessly pollute the configuration file.
We take care of both problems by
purge_null_valuesmethod to explicitly clean a dictionary of any null values;closes #31