From e78d509e5b53a72da287451a8d1b8b1280c992fa Mon Sep 17 00:00:00 2001 From: Rohan R Bharadwaj Date: Sun, 7 Nov 2021 14:17:07 +0530 Subject: [PATCH 1/2] [mypy] Fix `other/fischer_yates_shuffle.py` --- other/fischer_yates_shuffle.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/other/fischer_yates_shuffle.py b/other/fischer_yates_shuffle.py index 035fcb482380..fa2f4dce9db0 100644 --- a/other/fischer_yates_shuffle.py +++ b/other/fischer_yates_shuffle.py @@ -6,14 +6,15 @@ wikipedia/Fischer-Yates-Shuffle. """ import random +from typing import Any -def fisher_yates_shuffle(data: list) -> list: - for _ in range(len(list)): - a = random.randint(0, len(list) - 1) - b = random.randint(0, len(list) - 1) - list[a], list[b] = list[b], list[a] - return list +def fisher_yates_shuffle(data: list) -> list[Any]: + for _ in range(len(data)): + a = random.randint(0, len(data) - 1) + b = random.randint(0, len(data) - 1) + data[a], data[b] = data[b], data[a] + return data if __name__ == "__main__": From 90c584818fd5bb94ebbb5da53d0625d0eae4ada1 Mon Sep 17 00:00:00 2001 From: Rohan R Bharadwaj Date: Sun, 7 Nov 2021 14:23:26 +0530 Subject: [PATCH 2/2] Update mypy.ini --- mypy.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy.ini b/mypy.ini index 1a2282c44846..123ffae851a5 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2,5 +2,5 @@ ignore_missing_imports = True install_types = True non_interactive = True -exclude = (data_structures/stacks/next_greater_element.py|graphs/boruvka.py|graphs/breadth_first_search.py|graphs/breadth_first_search_2.py|graphs/check_cycle.py|graphs/finding_bridges.py|graphs/greedy_min_vertex_cover.py|graphs/random_graph_generator.py|maths/average_mode.py|maths/gamma_recursive.py|maths/proth_number.py|maths/series/geometric_series.py|maths/series/p_series.py|matrix_operation.py|other/fischer_yates_shuffle.py|other/least_recently_used.py|other/lfu_cache.py|other/lru_cache.py|searches/simulated_annealing.py|searches/ternary_search.py) +exclude = (data_structures/stacks/next_greater_element.py|graphs/boruvka.py|graphs/breadth_first_search.py|graphs/breadth_first_search_2.py|graphs/check_cycle.py|graphs/finding_bridges.py|graphs/greedy_min_vertex_cover.py|graphs/random_graph_generator.py|maths/average_mode.py|maths/gamma_recursive.py|maths/proth_number.py|maths/series/geometric_series.py|maths/series/p_series.py|matrix_operation.py|other/least_recently_used.py|other/lfu_cache.py|other/lru_cache.py|searches/simulated_annealing.py|searches/ternary_search.py)