def yaml_padding_from_line(line: str) -> int:
    """Calculate number of spaces required to create a YAML multiline string.

    eg:
        line='foo: bar' -> 2
        line='  foo: bar' -> 4
    """
    last_c = None
    padding = 0
    for i, c in enumerate(line):
        if i == 0 and c != ' ':
            padding = 2
            break
        if last_c == ' ' and c != ' ':
            padding = i + 2
            break
        last_c = c
        padding = i
    return padding