yaml
yaml
¶
YAML configuration loading for BigBrotr.
Provides safe YAML file loading using yaml.safe_load to prevent
arbitrary code execution from untrusted YAML content. Used by
Pool.from_yaml(),
Brotr.from_yaml(), and
BaseService.from_yaml()
to load their configuration files.
Examples:
See Also
Pool.from_yaml(): Pool factory that delegates to this function. Brotr.from_yaml(): Brotr factory that delegates to this function. BaseService.from_yaml(): Service factory that delegates to this function. BaseServiceConfig: Typical Pydantic model constructed from the returned dictionary.
Functions¶
load_yaml
¶
Load and parse a YAML configuration file.
Uses yaml.safe_load which only supports standard YAML types
(strings, numbers, lists, dicts) and prevents arbitrary Python
object instantiation from YAML tags.
Parameters:
-
config_path(str) –Path to the YAML file (absolute or relative).
Returns:
-
dict[str, Any]–Parsed configuration as a nested dictionary. Returns an empty dict
-
dict[str, Any]–if the file exists but contains no data.
Raises:
-
FileNotFoundError–If the file does not exist.
-
YAMLError–If the file contains invalid YAML syntax.
-
TypeError–If the file content is not a YAML mapping.
Warning
This function does not validate the structure of the returned dictionary. Callers are responsible for passing the result to a Pydantic model (e.g. PoolConfig, BrotrConfig, BaseServiceConfig) for schema validation.
See Also
Pool.from_yaml(): Primary consumer for pool configuration. Brotr.from_yaml(): Primary consumer for database interface configuration. BaseService.from_yaml(): Primary consumer for service configuration.