def format_size(num: int, align=False, default='{} BYTE') ->str:
    """
    Given a number of bytes, produce a human-readable expression for this
    size using common units such as kB and MB.
    """
    step = 1000.0
    result = num
    for unit in ['#B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']:
        if result / step < 0.1:
            break
        result /= step
    if unit == '#B' and not align:
        return default.format(num)
    else:
        width = 6 if align else ''
        return f'{result:{width}.3f} {unit}'
