Parse a time/string and return a datetime.time.

    This function doesn't support time zone offsets.

    Raise ValueError if the input is well formatted but not a valid time.
    Raise ValueError if the input isn't well formatted, in particular if it contains an offset.

def parse_time(value: Union[time, str]) -> time:
    """
    Parse a time/string and return a datetime.time.

    This function doesn't support time zone offsets.

    Raise ValueError if the input is well formatted but not a valid time.
    Raise ValueError if the input isn't well formatted, in particular if it contains an offset.
    """
    if isinstance(value, time):
        return value

    match = time_re.match(value)
    if not match:
        raise errors.TimeError()

    kw = match.groupdict()
    if kw['microsecond']:
        kw['microsecond'] = kw['microsecond'].ljust(6, '0')

    kw_ = {k: int(v) for k, v in kw.items() if v is not None}

    with change_exception(errors.TimeError, ValueError):
        return time(**kw_)