From 8139fca4b7ac27334dd65446eeb394baf625695b Mon Sep 17 00:00:00 2001 From: Rohan R Bharadwaj Date: Mon, 8 Nov 2021 15:28:07 +0530 Subject: [PATCH 01/11] [mypy] Annotate `graphs/finding_bridges.py` --- graphs/finding_bridges.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphs/finding_bridges.py b/graphs/finding_bridges.py index a877a97489be..ff550dca1873 100644 --- a/graphs/finding_bridges.py +++ b/graphs/finding_bridges.py @@ -93,7 +93,7 @@ def dfs(at, parent, bridges, id): # This edge is a back edge and cannot be a bridge low[at] = min(low[at], low[to]) - bridges = [] + bridges: list[tuple[int, int]] = [] for i in range(n): if not visited[i]: dfs(i, -1, bridges, id) From 63a66bb39ae9f5f65a1c04552021d3b02cbc4d1a Mon Sep 17 00:00:00 2001 From: Rohan R Bharadwaj Date: Mon, 8 Nov 2021 15:35:30 +0530 Subject: [PATCH 02/11] Remove from excluded in `mypy.ini` --- mypy.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy.ini b/mypy.ini index df69fa841cef..44c81dd0ee78 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2,4 +2,4 @@ ignore_missing_imports = True install_types = True non_interactive = True -exclude = (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|matrix_operation.py|other/least_recently_used.py|other/lfu_cache.py|other/lru_cache.py|searches/simulated_annealing.py|searches/ternary_search.py) +exclude = (graphs/boruvka.py|graphs/breadth_first_search.py|graphs/breadth_first_search_2.py|graphs/check_cycle.py|graphs/greedy_min_vertex_cover.py|graphs/random_graph_generator.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) From ef4066a14bd1ee3fed2ce7150cb4502a7c572fbc Mon Sep 17 00:00:00 2001 From: Rohan R Bharadwaj Date: Mon, 8 Nov 2021 15:42:24 +0530 Subject: [PATCH 03/11] Add doctest.testmod() --- graphs/finding_bridges.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/graphs/finding_bridges.py b/graphs/finding_bridges.py index ff550dca1873..f2a1ad7f533a 100644 --- a/graphs/finding_bridges.py +++ b/graphs/finding_bridges.py @@ -98,3 +98,8 @@ def dfs(at, parent, bridges, id): if not visited[i]: dfs(i, -1, bridges, id) return bridges + +if __name__ == "__main__": + import doctest + + doctest.testmod() From 81136e56ecf07544f17ae86ce19d07b5629f3d66 Mon Sep 17 00:00:00 2001 From: Rohan R Bharadwaj Date: Mon, 8 Nov 2021 15:47:29 +0530 Subject: [PATCH 04/11] psf/black formatting --- graphs/finding_bridges.py | 1 + 1 file changed, 1 insertion(+) diff --git a/graphs/finding_bridges.py b/graphs/finding_bridges.py index f2a1ad7f533a..3813c4ebbd2a 100644 --- a/graphs/finding_bridges.py +++ b/graphs/finding_bridges.py @@ -99,6 +99,7 @@ def dfs(at, parent, bridges, id): dfs(i, -1, bridges, id) return bridges + if __name__ == "__main__": import doctest From 18615a752797459b875456d3c470792dc66080a9 Mon Sep 17 00:00:00 2001 From: Rohan R Bharadwaj Date: Mon, 8 Nov 2021 16:25:08 +0530 Subject: [PATCH 05/11] Annotations for `graphs/random_graph_generator.py` --- graphs/random_graph_generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphs/random_graph_generator.py b/graphs/random_graph_generator.py index d7d5de8a37c0..15ccee5b399c 100644 --- a/graphs/random_graph_generator.py +++ b/graphs/random_graph_generator.py @@ -26,7 +26,7 @@ def random_graph( >>> random_graph(4, 0.5, True) {0: [1], 1: [2, 3], 2: [3], 3: []} """ - graph = {i: [] for i in range(vertices_number)} + graph: dict = {i: [] for i in range(vertices_number)} # if probability is greater or equal than 1, then generate a complete graph if probability >= 1: From f559abc50629d3543112e1759ccdd4e4f8870724 Mon Sep 17 00:00:00 2001 From: Rohan R Bharadwaj Date: Mon, 8 Nov 2021 16:29:13 +0530 Subject: [PATCH 06/11] Remove from excluded in `mypy.ini` --- mypy.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy.ini b/mypy.ini index 44c81dd0ee78..b4b8db3100c8 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2,4 +2,4 @@ ignore_missing_imports = True install_types = True non_interactive = True -exclude = (graphs/boruvka.py|graphs/breadth_first_search.py|graphs/breadth_first_search_2.py|graphs/check_cycle.py|graphs/greedy_min_vertex_cover.py|graphs/random_graph_generator.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) +exclude = (graphs/boruvka.py|graphs/breadth_first_search.py|graphs/breadth_first_search_2.py|graphs/check_cycle.py|graphs/greedy_min_vertex_cover.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) From cdd15711fb80f248cf8c4ed187d0bbb788b2410c Mon Sep 17 00:00:00 2001 From: Rohan R Bharadwaj Date: Mon, 8 Nov 2021 20:53:25 +0530 Subject: [PATCH 07/11] Resolve merge conflict --- mypy.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy.ini b/mypy.ini index b4b8db3100c8..16ca60c4dbcc 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2,4 +2,4 @@ ignore_missing_imports = True install_types = True non_interactive = True -exclude = (graphs/boruvka.py|graphs/breadth_first_search.py|graphs/breadth_first_search_2.py|graphs/check_cycle.py|graphs/greedy_min_vertex_cover.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) +exclude = (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|matrix_operation.py|other/least_recently_used.py|other/lfu_cache.py|other/lru_cache.py|searches/simulated_annealing.py|searches/ternary_search.py) From 2d2f4229cf7b94fd28e0ad30691c495c4cecd06b Mon Sep 17 00:00:00 2001 From: Rohan R Bharadwaj Date: Mon, 8 Nov 2021 20:54:44 +0530 Subject: [PATCH 08/11] Resolve merge conflict --- mypy.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy.ini b/mypy.ini index 16ca60c4dbcc..429c6804daf5 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2,4 +2,4 @@ ignore_missing_imports = True install_types = True non_interactive = True -exclude = (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|matrix_operation.py|other/least_recently_used.py|other/lfu_cache.py|other/lru_cache.py|searches/simulated_annealing.py|searches/ternary_search.py) +exclude = (graphs/breadth_first_search.py|graphs/breadth_first_search_2.py|graphs/check_cycle.py|graphs/greedy_min_vertex_cover.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) From 7a6f4f6ada93b652b68ff2b3721a0a50788dfb81 Mon Sep 17 00:00:00 2001 From: Rohan R Bharadwaj Date: Mon, 8 Nov 2021 20:55:51 +0530 Subject: [PATCH 09/11] Update mypy.ini --- mypy.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy.ini b/mypy.ini index 429c6804daf5..1f40adf962bd 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2,4 +2,4 @@ ignore_missing_imports = True install_types = True non_interactive = True -exclude = (graphs/breadth_first_search.py|graphs/breadth_first_search_2.py|graphs/check_cycle.py|graphs/greedy_min_vertex_cover.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) +exclude = exclude = (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|matrix_operation.py|other/least_recently_used.py|other/lfu_cache.py|other/lru_cache.py|searches/simulated_annealing.py|searches/ternary_search.py) From 2500431ee6d02700da65996bd9ee14983665695c Mon Sep 17 00:00:00 2001 From: Rohan R Bharadwaj Date: Mon, 8 Nov 2021 20:56:13 +0530 Subject: [PATCH 10/11] Update mypy.ini --- mypy.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy.ini b/mypy.ini index 1f40adf962bd..df69fa841cef 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2,4 +2,4 @@ ignore_missing_imports = True install_types = True non_interactive = True -exclude = exclude = (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|matrix_operation.py|other/least_recently_used.py|other/lfu_cache.py|other/lru_cache.py|searches/simulated_annealing.py|searches/ternary_search.py) +exclude = (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|matrix_operation.py|other/least_recently_used.py|other/lfu_cache.py|other/lru_cache.py|searches/simulated_annealing.py|searches/ternary_search.py) From ec08e38b249b551928fc1b082a5648fc79c59b39 Mon Sep 17 00:00:00 2001 From: Rohan R Bharadwaj Date: Mon, 8 Nov 2021 21:00:26 +0530 Subject: [PATCH 11/11] Remove from excluded --- mypy.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy.ini b/mypy.ini index 16ca60c4dbcc..429c6804daf5 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2,4 +2,4 @@ ignore_missing_imports = True install_types = True non_interactive = True -exclude = (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|matrix_operation.py|other/least_recently_used.py|other/lfu_cache.py|other/lru_cache.py|searches/simulated_annealing.py|searches/ternary_search.py) +exclude = (graphs/breadth_first_search.py|graphs/breadth_first_search_2.py|graphs/check_cycle.py|graphs/greedy_min_vertex_cover.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)