YamlBaseSettings#

pydantic settings safir.pydantic.YamlBaseSettings#

Base class for Pydantic settings from a YAML file.

This class is intended to serve as the base class for application settings when the settings are primarily parsed from a YAML configuration file with optional overrides and secrets from environment variables. It enables camel case for validation, allowing all parameters to be specified in the camel-case format that is standard for Helm charts. It also forbids extra settings and disables settings sources other than the constructor (used when reading YAML files) and environment variables.

It is normally used in conjunction with ConfigDependency.

Parameters:

Show JSON schema
{
   "title": "YamlBaseSettings",
   "description": "Base class for Pydantic settings from a YAML file.\n\nThis class is intended to serve as the base class for application settings\nwhen the settings are primarily parsed from a YAML configuration file with\noptional overrides and secrets from environment variables. It enables\ncamel case for validation, allowing all parameters to be specified in the\ncamel-case format that is standard for Helm charts. It also forbids extra\nsettings and disables settings sources other than the constructor (used\nwhen reading YAML files) and environment variables.\n\nIt is normally used in conjunction with\n`~safir.dependencies.config.ConfigDependency`.",
   "type": "object",
   "properties": {},
   "additionalProperties": false
}

Config:
  • alias_generator: AliasGenerator = AliasGenerator(alias=None, validation_alias=<function YamlBaseSettings.<lambda> at 0x73f1017a4eb0>, serialization_alias=None)

  • validate_by_name: bool = True

classmethod from_file(path)#

Construct a settings object from a configuration file.

Parameters:

path (Path) – Path to the configuration file in YAML.

Returns:

The corresponding settings object.

Return type:

YamlBaseSettings