Skip to content

Commit accee50

Browse files
[mypy] Fix other/fischer_yates_shuffle.py (#5789)
* [mypy] Fix `other/fischer_yates_shuffle.py` * Update mypy.ini
1 parent 8ac86f2 commit accee50

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

mypy.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
ignore_missing_imports = True
33
install_types = True
44
non_interactive = True
5-
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)
5+
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)
66

other/fischer_yates_shuffle.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
wikipedia/Fischer-Yates-Shuffle.
77
"""
88
import random
9+
from typing import Any
910

1011

11-
def fisher_yates_shuffle(data: list) -> list:
12-
for _ in range(len(list)):
13-
a = random.randint(0, len(list) - 1)
14-
b = random.randint(0, len(list) - 1)
15-
list[a], list[b] = list[b], list[a]
16-
return list
12+
def fisher_yates_shuffle(data: list) -> list[Any]:
13+
for _ in range(len(data)):
14+
a = random.randint(0, len(data) - 1)
15+
b = random.randint(0, len(data) - 1)
16+
data[a], data[b] = data[b], data[a]
17+
return data
1718

1819

1920
if __name__ == "__main__":

0 commit comments

Comments
 (0)