Skip to content

yaml

dumps(py_data, *, sort_keys=True, default_flow_style=False)

Dump data as yaml using the safe_dump method.

Parameters:

Name Type Description Default
py_data Any

Any object that may be serialized.

required
sort_keys bool

Whether to sort the keys.

True
default_flow_style bool | None

Whether to use the default flow style.

False

Returns:

Type Description
str

A yaml serialized string.

Source code in m/core/yaml.py
def dumps(
    py_data: Any,
    *,
    sort_keys: bool = True,
    default_flow_style: bool | None = False,
) -> str:
    """Dump data as yaml using the safe_dump method.

    Args:
        py_data: Any object that may be serialized.
        sort_keys: Whether to sort the keys.
        default_flow_style: Whether to use the default flow style.

    Returns:
        A yaml serialized string.
    """
    return yaml.dump(
        py_data,
        Dumper=_SafeDumper,
        sort_keys=sort_keys,
        default_flow_style=default_flow_style,
    )