def parse_time(time_str: str) -> Optional[dt.time]:
    'Parse a time string (00:20:00) into Time object.\n\n    Return None if invalid.\n    '
    parts = str(time_str).split(':')
    if (len(parts) < 2):
        return None
    try:
        hour = int(parts[0])
        minute = int(parts[1])
        second = (int(parts[2]) if (len(parts) > 2) else 0)
        return dt.time(hour, minute, second)
    except ValueError:
        return None
Parse a time string (00:20:00) into Time object.

Return None if invalid.
def parse_time(time_str: str) -> Optional[dt.time]:
    'Parse a time string (00:20:00) into Time object.\n\n    Return None if invalid.\n    '
    parts = str(time_str).split(':')
    if (len(parts) < 2):
        return None
    try:
        hour = int(parts[0])
        minute = int(parts[1])
        second = (int(parts[2]) if (len(parts) > 2) else 0)
        return dt.time(hour, minute, second)
    except ValueError:
        return None