diff --git a/anonymize_data.py b/anonymize_data.py index 089bf6a..f260e40 100644 --- a/anonymize_data.py +++ b/anonymize_data.py @@ -65,7 +65,7 @@ def get_review_token_indices( def get_author_name_token_index( - ballot_year: str = "2018", + ballot_year: str | int = "2018", *, is_anonymized: bool = False, ) -> int: diff --git a/parsing_params.py b/parsing_params.py index 0812cc5..996523b 100644 --- a/parsing_params.py +++ b/parsing_params.py @@ -48,11 +48,14 @@ def adjust_params_to_year(params: dict[str, dict], year: str | int) -> dict[str, return params -def get_adjusted_parsing_params(year): +def get_adjusted_parsing_params(year: str | int): return adjust_params_to_year(get_default_parsing_params(), year) -def get_next_indices(last_index: int = 0, num_indices: int = 0) -> tuple[int, int, int]: +def get_next_indices( + last_index: int = 0, + num_indices: int = 0, +) -> tuple[int, int, int | None]: # The first index to include start = 1 + last_index @@ -67,7 +70,7 @@ def get_next_indices(last_index: int = 0, num_indices: int = 0) -> tuple[int, in def convert_params_to_indices( params: dict[str, dict], offset: int = 9, -) -> dict[str, dict]: +) -> dict: voter_index = offset indices = { @@ -108,9 +111,9 @@ def get_parsing_offset(*, is_anonymized: bool) -> int: return 0 if is_anonymized else 9 -def get_parsing_indices(year, is_anonymized): +def get_parsing_indices(year: str | int, is_anonymized: bool): params = get_adjusted_parsing_params(year=year) - offset = get_parsing_offset(is_anonymized) + offset = get_parsing_offset(is_anonymized=is_anonymized) return convert_params_to_indices(params, offset) diff --git a/parsing_utils.py b/parsing_utils.py index e62471e..0989ee9 100644 --- a/parsing_utils.py +++ b/parsing_utils.py @@ -37,7 +37,7 @@ def parse_csv(fname: str, parsing_params): if not is_anonymized: text_data = remove_header(text_data) - return parse_text_data(text_data, parsing_params, is_anonymized) + return parse_text_data(text_data, parsing_params, is_anonymized=is_anonymized) def parse_text_data( @@ -58,7 +58,7 @@ def parse_text_data( voter_name = read_voter_name(tokens, indices) - single_ballot = {} + single_ballot: dict = {} single_ballot = fill_in_review(tokens, indices, single_ballot=single_ballot) single_ballot = fill_in_game_list( tokens, diff --git a/schulze_optional.py b/schulze_optional.py index 6443e3a..922b350 100644 --- a/schulze_optional.py +++ b/schulze_optional.py @@ -12,21 +12,21 @@ def apply_pipeline_for_optional_categories( - input_filename, - release_year="2020", + input_filename: str, + release_year: str = "2020", *, - try_to_break_ties=True, - use_igdb=True, - retrieve_igdb_data_from_scratch=True, - apply_hard_coded_extension_and_fixes=True, - use_levenshtein_distance=True, - goty_field="goty_preferences", - year_constraint="equality", - print_matches=True, - num_app_id_groups_to_display=3, - must_be_available_on_pc=False, - must_be_a_game=False, - verbose=False, + try_to_break_ties: bool = True, + use_igdb: bool = True, + retrieve_igdb_data_from_scratch: bool = True, + apply_hard_coded_extension_and_fixes: bool = True, + use_levenshtein_distance: bool = True, + goty_field: str = "goty_preferences", + year_constraint: str = "equality", + print_matches: bool = True, + num_app_id_groups_to_display: int = 3, + must_be_available_on_pc: bool = False, + must_be_a_game: bool = False, + verbose: bool = False, ) -> bool: ballots = load_ballots(input_filename) diff --git a/tests.py b/tests.py index 921340d..8c33bac 100644 --- a/tests.py +++ b/tests.py @@ -411,7 +411,7 @@ def test_filtering_out(self) -> None: def test_filter_out_votes_for_early_access_titles(self) -> None: ballot_year = "2018" - ballots = {} + ballots: dict = {} # Add dummy vote for an Early Access game ballots["dummy_voter_name"] = {} @@ -810,7 +810,7 @@ def test_figure_out_ballots_with_missing_data(self) -> None: dummy_voter = "dummy_voter_name" goty_field = "dummy_preferences" - ballots = {} + ballots: dict = {} ballots[dummy_voter] = {} ballots[dummy_voter][goty_field] = {} ballots[dummy_voter][goty_field][1] = "Hello" @@ -844,7 +844,7 @@ def test_figure_out_ballots_with_missing_data(self) -> None: def test_load_igdb_local_databases(self) -> None: ballot_year = "2018" - ballots = {} + ballots: dict = {} # Add dummy votes for the two actual GotY 2018 on MetaCouncil ballots["dummy_voter_name"] = {} @@ -925,7 +925,7 @@ def test_load_igdb_match_database(self) -> None: assert data is not None def test_save_igdb_match_database(self) -> None: - data = {} + data: dict = {} file_name = "data/dummy_match_file_for_unit_test.json" igdb_databases.save_igdb_match_database(data, file_name=file_name) assert Path(file_name).exists() @@ -936,7 +936,7 @@ def test_load_igdb_local_database(self) -> None: assert data is not None def test_save_igdb_local_database(self) -> None: - data = {} + data: dict = {} file_name = "data/dummy_local_file_for_unit_test.json" igdb_databases.save_igdb_local_database(data, file_name=file_name) assert Path(file_name).exists()