File tree 2 files changed +7
-6
lines changed
2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change 2
2
An AST.
3
3
"""
4
4
5
- from typing import TypeAlias , NewType
5
+ from typing import TypeAlias , NewType , Literal
6
6
import enum
7
7
import datetime
8
8
import dataclasses
@@ -15,6 +15,7 @@ class StopPart(enum.Enum):
15
15
A part of a Stop (e.g. Gleason Circle *Arrival*).
16
16
"""
17
17
18
+ NONE = "none"
18
19
ARRIVAL = "arrival"
19
20
DEPARTURE = "departure"
20
21
@@ -23,8 +24,8 @@ class StopPart(enum.Enum):
23
24
StopIdx = NewType ("StopIdx" , int )
24
25
25
26
26
- TimeTableColumn : TypeAlias = tuple [StopIdx , StopPart | None ]
27
- TimeTableCell : TypeAlias = datetime .time | None
27
+ TimeTableColumn : TypeAlias = tuple [StopIdx , StopPart ]
28
+ TimeTableCell : TypeAlias = datetime .time | Literal [ "none" ]
28
29
29
30
30
31
@serde .serde
Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ def _route(s_route: ScrapedRoute) -> Route:
135
135
LAST_WORD_RE = re .compile ("(.*) (.*)$" )
136
136
137
137
138
- def _stop (s_time_table_col : ScrapedTimeTableColumn ) -> tuple [Stop , StopPart | None ]:
138
+ def _stop (s_time_table_col : ScrapedTimeTableColumn ) -> tuple [Stop , StopPart ]:
139
139
last_match = LAST_WORD_RE .match (s_time_table_col )
140
140
last = last_match [2 ] if last_match is not None else None
141
141
@@ -147,7 +147,7 @@ def _stop(s_time_table_col: ScrapedTimeTableColumn) -> tuple[Stop, StopPart | No
147
147
assert last_match is not None
148
148
stop = last_match [1 ].strip ()
149
149
except ValueError :
150
- stop_part = None
150
+ stop_part = StopPart ( "none" )
151
151
stop = s_time_table_col
152
152
153
153
return (stop , stop_part )
@@ -178,7 +178,7 @@ def _time_table_n_stop(
178
178
179
179
def _time_table_cell (s_time_table_cell : ScrapedTimeTableCell ) -> TimeTableCell :
180
180
if s_time_table_cell is None :
181
- return None
181
+ return "none"
182
182
183
183
date_time = datetime .datetime .strptime (s_time_table_cell , RAW_CELL_TIME_FORMAT )
184
184
return date_time .time ()
You can’t perform that action at this time.
0 commit comments