Skip to content

Commit fe9ae4b

Browse files
chore: fix mypy errors
1 parent b38a74c commit fe9ae4b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/adventofcode/year_2015/day_16_2015.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List, Dict
1+
from typing import List, Dict, Optional
22

33
from adventofcode.util.exceptions import SolutionNotFoundException
44
from adventofcode.util.helpers import solution_timer
@@ -44,11 +44,13 @@ def parse_lines(input_data: List[str]) -> List[Aunt]:
4444
return aunts
4545

4646

47-
def find_aunt_sue(aunts: List[Aunt]) -> Aunt:
47+
def find_aunt_sue(aunts: List[Aunt]) -> Optional[Aunt]:
4848
for aunt in aunts:
4949
if all_properties_match(aunt):
5050
return aunt
5151

52+
return None
53+
5254

5355
def find_aunt_sue_part_two(aunts: List[Aunt]) -> Aunt:
5456
aunts = [aunt for aunt in aunts if matches_part_two(aunt)]
@@ -84,7 +86,12 @@ def matches_part_two(aunt: Aunt) -> bool:
8486
@solution_timer(2015, 16, 1)
8587
def part_one(input_data: List[str]):
8688
aunts = parse_lines(input_data)
87-
answer = find_aunt_sue(aunts).number
89+
aunt = find_aunt_sue(aunts)
90+
91+
if not aunt:
92+
raise SolutionNotFoundException(2015, 16, 1)
93+
94+
answer = aunt.number
8895

8996
if not answer:
9097
raise SolutionNotFoundException(2015, 16, 1)

0 commit comments

Comments
 (0)