fix: raise ParseError for out-of-range times

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
rickzkmandClaude Sonnet 5.5 committed 2026-10-07 00:23:54 +02:00
1 parent 8099b4834b
commit ba35014a06
2 files changed
+23 -1

No files matched your search

+5 -1
View File
@@ -93,7 +93,11 @@ def parse_page(html: str, line: str, stop: str) -> Timetable:
raise ParseError(f"hour {hour}: {len(cells)} cells for {len(specs)} columns")
for column, cell in zip(per_column, cells):
for minute, mark in _MINUTE_RE.findall(cell):
column.append(Departure(line, stop, time(int(hour), int(minute)), mark or None))
try:
departure_time = time(int(hour), int(minute))
except ValueError:
raise ParseError(f"hour {hour}: invalid time {hour}:{minute}")
column.append(Departure(line, stop, departure_time, mark or None))
if not any(per_column):
raise ParseError("timetable contains no departures")