Skip to content

Commit 5dd8960

Browse files
committed
Add bound types for Mentor and Mentee
1 parent f80d983 commit 5dd8960

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

matching/process.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pathlib
55
import sys
66
from pathlib import Path
7-
from typing import Union, Type, List, Dict, Tuple, Generator, Callable
7+
from typing import Union, Type, List, Dict, Tuple, Generator, Callable, TypeVar
88

99
from munkres import Munkres, make_cost_matrix, Matrix # type: ignore
1010

@@ -16,8 +16,14 @@
1616
from matching.export import ExportToSpreadsheet
1717

1818

19+
MenteeType = TypeVar("MenteeType", bound=Mentee)
20+
MentorType = TypeVar("MentorType", bound=Mentor)
21+
22+
1923
def generate_match_matrix(
20-
mentor_list: List[Mentor], mentee_list: List[Mentee], rules: List[rl.RuleProtocol]
24+
mentor_list: List[MentorType],
25+
mentee_list: List[MenteeType],
26+
rules: List[rl.RuleProtocol],
2127
) -> List[List[Match]]:
2228
return [
2329
[Match(mentor, mentee, rules).calculate_match() for mentee in mentee_list]
@@ -92,8 +98,10 @@ def match_and_assign_participants(
9298

9399

94100
def process_data(
95-
mentors: List[Mentor], mentees: List[Mentee], all_rules: List[List[rl.RuleProtocol]]
96-
) -> Tuple[List[Mentor], List[Mentee]]:
101+
mentors: List[MentorType],
102+
mentees: List[MenteeType],
103+
all_rules: List[List[rl.RuleProtocol]],
104+
) -> Tuple[List[MentorType], List[MenteeType]]:
97105
"""
98106
This is the main entrypoint for this software. It lazily generates three matrices, which allows for them to be
99107
mutated over the course of the matching process.
@@ -113,7 +121,7 @@ def process_data(
113121

114122
def conduct_matching_from_file(
115123
path_to_data: Path, rules: list[list[rl.RuleProtocol]]
116-
) -> Tuple[List[Mentor], List[Mentee]]:
124+
) -> Tuple[List[MentorType], List[MenteeType]]:
117125
mentors = create_participant_list_from_path(Mentor, path_to_data)
118126
mentees = create_participant_list_from_path(Mentee, path_to_data)
119127
return process_data(mentors, mentees, rules)

0 commit comments

Comments
 (0)