10
10
import typer
11
11
from urllib3 .exceptions import MaxRetryError
12
12
13
- from aoc .base import BaseSolution
13
+ from aoc .base import BaseSolution , Output
14
14
15
15
app = typer .Typer (no_args_is_help = True )
16
16
@@ -192,9 +192,9 @@ def run(
192
192
ans1 , ans2 = solve (puzzle )
193
193
194
194
if ans1 is not None :
195
- out_file_a .write_text (ans1 )
195
+ out_file_a .write_text (str ( ans1 ) )
196
196
if ans2 is not None :
197
- out_file_b .write_text (ans2 )
197
+ out_file_b .write_text (str ( ans2 ) )
198
198
199
199
rich .print (f"Part a: { ans1 } \n Part b: { ans2 } " )
200
200
@@ -215,22 +215,12 @@ def submit(
215
215
ans1 , ans2 = solve (puzzle )
216
216
217
217
if ans1 is not None :
218
- puzzle .answer_a = ans1
218
+ puzzle .answer_a = ans1 # pyright: ignore[reportAttributeAccessIssue]
219
219
if ans2 is not None :
220
- puzzle .answer_b = ans2
220
+ puzzle .answer_b = ans2 # pyright: ignore[reportAttributeAccessIssue]
221
221
222
222
223
- def coerce_solution (solution : str | int | None ) -> None | str :
224
- match solution :
225
- case None :
226
- return None
227
- case str ():
228
- return solution
229
- case int ():
230
- return str (solution )
231
-
232
-
233
- def solve (puzzle : Puzzle ) -> tuple [str | None , str | None ]:
223
+ def solve (puzzle : Puzzle ) -> tuple [Output | None , Output | None ]:
234
224
mod = importlib .import_module (f"aoc.Y{ puzzle .year } .D{ puzzle .day :0>2} .main" )
235
225
236
226
solution = cast (BaseSolution [Any , Any ], mod .Solution ())
@@ -240,7 +230,7 @@ def solve(puzzle: Puzzle) -> tuple[str | None, str | None]:
240
230
part1 = solution .part1 (transformed )
241
231
part2 = solution .part2 (transformed )
242
232
243
- return (coerce_solution ( part1 ), coerce_solution ( part2 ) )
233
+ return (part1 , part2 )
244
234
245
235
246
236
def main () -> None :
0 commit comments