utils.format

format_as_yaml

Format data as YAML with multiline string support.

This function uses a custom YAML dumper that automatically formats strings containing newlines as multiline YAML strings using the ‘|’ style, and enums as their string values.

def format_as_yaml(data: Any, strip_spaces: str | None = None, **kwargs: Any) -> str
data Any

The data to format as YAML

strip_spaces str | None

Strip mode for string processing. Options: - ‘trailing’: Remove trailing spaces from each line - ‘lines’: Remove all spaces/tabs from lines composed entirely of spaces/tabs

**kwargs Any

Additional arguments passed to yaml.dump()

Returns

The formatted YAML string