Skip to content

Commit ac4bdfd

Browse files
dylanbuchigithub-actions
and
github-actions
authored
[mypy] Fix type annotations in graphs/boruvka.py (#5794)
* Fix type annotations in boruvka.py * Remove graphs/boruvka.py| * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
1 parent 2f6a7ae commit ac4bdfd

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

Diff for: DIRECTORY.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@
109109

110110
## Computer Vision
111111
* [Cnn Classification](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/cnn_classification.py)
112+
* [Flip Augmentation](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/flip_augmentation.py)
112113
* [Harris Corner](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/harris_corner.py)
113114
* [Mean Threshold](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/mean_threshold.py)
115+
* [Mosaic Augmentation](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/mosaic_augmentation.py)
114116

115117
## Conversions
116118
* [Binary To Decimal](https://github.com/TheAlgorithms/Python/blob/master/conversions/binary_to_decimal.py)
@@ -297,8 +299,8 @@
297299
* [Test Send File](https://github.com/TheAlgorithms/Python/blob/master/file_transfer/tests/test_send_file.py)
298300

299301
## Financial
302+
* [Equated Monthly Installments](https://github.com/TheAlgorithms/Python/blob/master/financial/equated_monthly_installments.py)
300303
* [Interest](https://github.com/TheAlgorithms/Python/blob/master/financial/interest.py)
301-
* [EMI Calculation](https://github.com/TheAlgorithms/Python/blob/master/financial/equated_monthly_installments.py)
302304

303305
## Fractals
304306
* [Julia Sets](https://github.com/TheAlgorithms/Python/blob/master/fractals/julia_sets.py)

Diff for: graphs/boruvka.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
"""
2727
from __future__ import annotations
2828

29+
from typing import Any
30+
2931

3032
class Graph:
3133
def __init__(self, num_of_nodes: int) -> None:
@@ -62,7 +64,7 @@ def set_component(self, u_node: int) -> None:
6264
for k in self.m_component:
6365
self.m_component[k] = self.find_component(k)
6466

65-
def union(self, component_size: list, u_node: int, v_node: int) -> None:
67+
def union(self, component_size: list[int], u_node: int, v_node: int) -> None:
6668
"""Union finds the roots of components for two nodes, compares the components
6769
in terms of size, and attaches the smaller one to the larger one to form
6870
single component"""
@@ -84,7 +86,7 @@ def boruvka(self) -> None:
8486
component_size = []
8587
mst_weight = 0
8688

87-
minimum_weight_edge: list[int] = [-1] * self.m_num_of_nodes
89+
minimum_weight_edge: list[Any] = [-1] * self.m_num_of_nodes
8890

8991
# A list of components (initialized to all of the nodes)
9092
for node in range(self.m_num_of_nodes):
@@ -119,7 +121,7 @@ def boruvka(self) -> None:
119121
minimum_weight_edge[component] = [u, v, w]
120122

121123
for edge in minimum_weight_edge:
122-
if edge != -1:
124+
if isinstance(edge, list):
123125
u, v, w = edge
124126

125127
u_component = self.m_component[u]

Diff for: mypy.ini

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

0 commit comments

Comments
 (0)