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
This RFE has potential to replace the proposal I made on #683
Which is the support for the following snippet
frompydanticimportBaseModel, ConfigDictfromdynaconfimportDynaconf, DynaBoxclassMySchema(BaseModel):
model_config=ConfigDict(extra='allow')
dynaconf_config=DynaBox(lazy_validation=True, settings_files=["settings.yaml"])
server: strport: intsettings=Dynaconf(
schema=MySchema, # replaces `validators` and is mutually exclusive
)
settings.set("server", 1234)
# don't raise because lazy_validation=True# if lazy_validation was false then .set would assume the need for validationprint(settings.server)
# raise validation error because settings is evaluated on the first attr access
Details:
Must keep the current validators working with no regression, the only caveat is that the user must choose only one validation strategy to use to avoid confusions
On Django the schema must be defined(or imported) inside the app/settings.py and passed to DjangoDynaconf, the same for FlaskDynaconf.
If validation is not lazy, then it will be called for every .set or .update, we have to ensure that inside loaders we can load multiple keys in bulk and validate once
Pydantic is not added as a hard dependency, can be added on the extra section, but on the docs it must be described to install pydantic along with Dynaconf
Support for Pydantic v2 only
Before invoking the validation, the keys on settings.as_dict() must be transformed to the proper case, the way it is defined on the schema (not sure if pydantic allows case insensitivity)
The text was updated successfully, but these errors were encountered:
There is a downside I overlooked about using composition over inheritance that I've overlooked in our last discussion: we don't get auto-complete out of the box (with composition), which is a very requested feature related to schema-based config.
This RFE has potential to replace the proposal I made on #683
Which is the support for the following snippet
Details:
validators
working with no regression, the only caveat is that the user must choose only one validation strategy to use to avoid confusionssettings.as_dict()
must be transformed to the proper case, the way it is defined on the schema (not sure if pydantic allows case insensitivity)The text was updated successfully, but these errors were encountered: