You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the end of validators.validate.validate the Validator("group.something_new", default=5), is executed and then default value is merged with current data, during that process dynaconf is calling parse_conf_data passing tomlfy=True which forces toml to evaluate the existing data again so.
In [1]: fromdynaconf.utils.parse_confimportparse_conf_dataIn [2]: data= {"TEST_LIST": ["1", "2"]}
In [3]: parse_conf_data(data, tomlfy=True)
Out[3]: {'TEST_LIST': [1, 2]}
In [4]: parse_conf_data(data, tomlfy=False)
Out[4]: {'TEST_LIST': ['1', '2']}
Possible solutions:
Change setdefault method to use tomlfy=False
Change parse_with_toml to avoid doing that transformation.
The text was updated successfully, but these errors were encountered:
3 years ago I made the wrong decision to pass validators defaults to
TOML parser.
Validator object is created at Python level, or at YAML level where
there is no need to use toml as parser.
TOML parser must ideally be used only on environment variables
where there is no type system available.
That said, this PR ensures toml will keep parsing values coming from
envvars, but setdefault method will stop passing `tomlfy=True`
so the type informed on the validator will be the type set as default
value.
The only possible breaking change on this is if someone is setting
defaults relying on TOML to parse the data, in that case, user
will need to manually call `parse_with_toml` on default data.
I think that is not a common case, if someone reports it as a broken
change, we can provide a new argument `parse_default_with_toml` on
the Validator object later.
Describe the bug
Execution
$ DYNACONF_GROUP__TEST_LIST="['1','2']" python app.py
expectation:
current behavior
What is happening?
At the end of validators.validate.validate the
Validator("group.something_new", default=5),
is executed and then default value is merged with current data, during that process dynaconf is callingparse_conf_data
passingtomlfy=True
which forces toml to evaluate the existing data again so.Possible solutions:
Change
setdefault
method to usetomlfy=False
Change
parse_with_toml
to avoid doing that transformation.The text was updated successfully, but these errors were encountered: