def format_unit(unit: str) -> str:
    """ Add a space before the unit if necessary, e.g. 'LOC' -> ' LOC', but '%' -> '%'. """
    return ' ' + unit if unit and unit != '%' and not unit.startswith(' ') else unit