def format_attribute(attribute):
    """Format a tuple describing an attribute.

    :param attribute: attribute tuple, which may be either ``(key, value)`` or
      ``(value,)``.
    :return: the formatted string

    If given, `key` is either formatted as itself, if it's a `str`, or else as
    ``repr(key)``, and is separated from `value` by an equal sign ("=").
    `value` is always formatted as ``repr(value)``.
    """
    if len(attribute) == 1:
        (value,) = attribute
        return repr(value)

    key, value = attribute
    value_str = repr(value)

    if isinstance(key, str):
        key_str = key
    else:
        key_str = repr(key)

    return f"{key_str}={value_str}"