Skip to content

Commit 84d15f9

Browse files
committed
ruff rule ANN202 missing-return-type-private-function
1 parent dbf22d3 commit 84d15f9

105 files changed

Lines changed: 268 additions & 260 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

data_structures/arrays/sudoku_solver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def cross(items_a, items_b):
4141
peers = {s: {x for u in units[s] for x in u} - {s} for s in squares}
4242

4343

44-
def test():
44+
def test() -> None:
4545
"""A set of unit tests."""
4646
assert len(squares) == 81
4747
assert len(unitlist) == 27
@@ -121,7 +121,7 @@ def eliminate(values, s, d):
121121
return values
122122

123123

124-
def display(values):
124+
def display(values) -> None:
125125
"""
126126
Display these values as a 2-D grid.
127127
"""
@@ -166,7 +166,7 @@ def search(values):
166166
return some(search(assign(values.copy(), s, d)) for d in values[s])
167167

168168

169-
def solve_all(grids, name="", showif=0.0):
169+
def solve_all(grids, name="", showif=0.0) -> None:
170170
"""
171171
Attempt to solve a sequence of grids. Report results.
172172
When showif is a number of seconds, display puzzles that take longer.

data_structures/binary_tree/binary_tree_mirror.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55

66

7-
def binary_tree_mirror_dict(binary_tree_mirror_dictionary: dict, root: int):
7+
def binary_tree_mirror_dict(binary_tree_mirror_dictionary: dict, root: int) -> None:
88
if not root or root not in binary_tree_mirror_dictionary:
99
return
1010
left_child, right_child = binary_tree_mirror_dictionary[root][:2]

data_structures/binary_tree/segment_tree.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def right(self, idx):
3535
"""
3636
return idx * 2 + 1
3737

38-
def build(self, idx, left, right):
38+
def build(self, idx, left, right) -> None:
3939
if left == right:
4040
self.st[idx] = self.A[left]
4141
else:
@@ -56,7 +56,7 @@ def update(self, a, b, val):
5656
"""
5757
return self.update_recursive(1, 0, self.N - 1, a - 1, b - 1, val)
5858

59-
def update_recursive(self, idx, left, right, a, b, val):
59+
def update_recursive(self, idx, left, right, a, b, val) -> bool:
6060
"""
6161
update(1, 1, N, a, b, v) for update val v to [a,b]
6262
"""
@@ -96,7 +96,7 @@ def query_recursive(self, idx, left, right, a, b):
9696
q2 = self.query_recursive(self.right(idx), mid + 1, right, a, b)
9797
return max(q1, q2)
9898

99-
def show_data(self):
99+
def show_data(self) -> None:
100100
show_list = []
101101
for i in range(1, self.N + 1):
102102
show_list += [self.query(i, i)]

data_structures/binary_tree/segment_tree_other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def __init__(self, collection: Sequence, function):
133133
if self.collection:
134134
self.root = self._build_tree(0, len(collection) - 1)
135135

136-
def update(self, i, val):
136+
def update(self, i, val) -> None:
137137
"""
138138
Update an element in log(N) time
139139
:param i: position to be update

data_structures/hashing/hash_table.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def _step_by_step(self, step_ord):
8585
print(list(range(len(self.values))))
8686
print(self.values)
8787

88-
def bulk_insert(self, values):
88+
def bulk_insert(self, values) -> None:
8989
"""
9090
bulk_insert is used for entering more than one element at a time
9191
in the HashTable.
@@ -236,15 +236,15 @@ def _collision_resolution(self, key, data=None):
236236

237237
return new_key
238238

239-
def rehashing(self):
239+
def rehashing(self) -> None:
240240
survivor_values = [value for value in self.values if value is not None]
241241
self.size_table = next_prime(self.size_table, factor=2)
242242
self._keys.clear()
243243
self.values = [None] * self.size_table # hell's pointers D: don't DRY ;/
244244
for value in survivor_values:
245245
self.insert_data(value)
246246

247-
def insert_data(self, data):
247+
def insert_data(self, data) -> None:
248248
"""
249249
insert_data is used for inserting a single element at a time in the HashTable.
250250

data_structures/hashing/tests/test_hash_map.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def _run_operation(obj, fun, *args):
7474
pytest.param(_add_with_resize_down, id="add with resize down"),
7575
],
7676
)
77-
def test_hash_map_is_the_same_as_dict(operations):
77+
def test_hash_map_is_the_same_as_dict(operations) -> None:
7878
my = HashMap(initial_block_size=4)
7979
py = {}
8080
for _, (fun, *args) in enumerate(operations):
@@ -87,7 +87,7 @@ def test_hash_map_is_the_same_as_dict(operations):
8787
assert set(my.items()) == set(py.items())
8888

8989

90-
def test_no_new_methods_was_added_to_api():
90+
def test_no_new_methods_was_added_to_api() -> None:
9191
def is_public(name: str) -> bool:
9292
return not name.startswith("_")
9393

data_structures/heap/binomial_heap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def merge_heaps(self, other):
203203
# Return the merged heap
204204
return self
205205

206-
def insert(self, val):
206+
def insert(self, val) -> None:
207207
"""
208208
insert a value in the heap
209209
"""

data_structures/heap/min_heap.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def build_heap(self, array):
6464
return array
6565

6666
# this is min-heapify method
67-
def sift_down(self, idx, array):
67+
def sift_down(self, idx, array) -> None:
6868
while True:
6969
left = self.get_left_child_idx(idx)
7070
right = self.get_right_child_idx(idx)
@@ -88,7 +88,7 @@ def sift_down(self, idx, array):
8888
else:
8989
break
9090

91-
def sift_up(self, idx):
91+
def sift_up(self, idx) -> None:
9292
p = self.get_parent_idx(idx)
9393
while p >= 0 and self.heap[p] > self.heap[idx]:
9494
self.heap[p], self.heap[idx] = self.heap[idx], self.heap[p]
@@ -114,7 +114,7 @@ def remove(self):
114114
self.sift_down(0, self.heap)
115115
return x
116116

117-
def insert(self, node):
117+
def insert(self, node) -> None:
118118
self.heap.append(node)
119119
self.idx_of_element[node] = len(self.heap) - 1
120120
self.heap_dict[node.name] = node.val
@@ -123,7 +123,7 @@ def insert(self, node):
123123
def is_empty(self):
124124
return len(self.heap) == 0
125125

126-
def decrease_key(self, node, new_value):
126+
def decrease_key(self, node, new_value) -> None:
127127
assert self.heap[self.idx_of_element[node]].val > new_value, (
128128
"newValue must be less that current value"
129129
)

data_structures/kd_tree/tests/test_kdtree.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
(10, 10.0, 3, -2, KDNode), # Depth = -2, 3D points
2424
],
2525
)
26-
def test_build_kdtree(num_points, cube_size, num_dimensions, depth, expected_result):
26+
def test_build_kdtree(
27+
num_points, cube_size, num_dimensions, depth, expected_result
28+
) -> None:
2729
"""
2830
Test that KD-Tree is built correctly.
2931
@@ -58,7 +60,7 @@ def test_build_kdtree(num_points, cube_size, num_dimensions, depth, expected_res
5860
)
5961

6062

61-
def test_nearest_neighbour_search():
63+
def test_nearest_neighbour_search() -> None:
6264
"""
6365
Test the nearest neighbor search function.
6466
"""
@@ -85,7 +87,7 @@ def test_nearest_neighbour_search():
8587
assert nodes_visited >= 0
8688

8789

88-
def test_edge_cases():
90+
def test_edge_cases() -> None:
8991
"""
9092
Test edge cases such as an empty KD-Tree.
9193
"""

data_structures/linked_list/doubly_linked_list.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ def __len__(self):
5757
"""
5858
return sum(1 for _ in self)
5959

60-
def insert_at_head(self, data):
60+
def insert_at_head(self, data) -> None:
6161
self.insert_at_nth(0, data)
6262

63-
def insert_at_tail(self, data):
63+
def insert_at_tail(self, data) -> None:
6464
self.insert_at_nth(len(self), data)
6565

66-
def insert_at_nth(self, index: int, data):
66+
def insert_at_nth(self, index: int, data) -> None:
6767
"""
6868
>>> linked_list = DoublyLinkedList()
6969
>>> linked_list.insert_at_nth(-1, 666)

0 commit comments

Comments
 (0)