def format_context(
    context: Context, formatter: typing.Union[str, Formatter] = "full"
) -> str:
    """Output the a context dictionary as a string."""
    if not context:
        return ""

    if callable(formatter):
        formatter_func = formatter
    else:
        if formatter in CONTEXT_FORMATTERS:
            formatter_func = CONTEXT_FORMATTERS[formatter]
        else:
            raise ValueError(f'Invalid context format: "{formatter}"')
    return formatter_func(context)
Output the a context dictionary as a string.