def format_seconds(total_seconds: float, *, precision: int=None) ->str:
    """
    Formats a number of seconds into meaningful units.

    If precision is specified as an int, then only this many of the largest
    non-zero units will be output in the string. Else, all will::

        >>> age = datetime.utcnow() - user.created_at
        >>> age_string = format_seconds(age.total_seconds(), precision=3)
        >>> print(age_string)
        33 days, 14 minutes, 12 seconds

    """
    mins, secs = divmod(total_seconds, 60)
    hrs, mins = divmod(mins, 60)
    days, hrs = divmod(hrs, 24)
    months, days = divmod(days, 30)
    years, months = divmod(months, 12)
    fmt = (lambda n, word: n and
        f"{n:.0f} {word}{int(n) - 1 and 's' or ''}" or '')
    queue = [fmt(years, 'year'), fmt(months, 'month'), fmt(days, 'day'),
        fmt(hrs, 'hour'), fmt(mins, 'minute'), fmt(secs, 'second')]
    queue = [*filter(None, queue)]
    if precision:
        queue = queue[:precision]
    return ', '.join(queue) or 'just now'
