prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Dev sprint ideas: More tests, type hints and less complexity
  currently, some of the programs use static type checking like this [program](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/fast_fibonacci.py) but some of the programs did not use static typing.
  
  it's a good practice to use static typing as it makes code more clear and readable, should we make it a standard for this repository.we can use [mypy](http://mypy-lang.org/) for testing code 
  
  [more on static typing](https://medium.com/@ageitgey/learn-how-to-use-static-type-checking-in-python-3-6-in-10-minutes-12c86d72677b)
   
  thank you
  
  ### Dev sprint ideas:
  * [ ] [Add tests to Python files with <10% test coverage.](https://github.com/TheAlgorithms/Python/issues/2128#issuecomment-645231020)
  * [ ] [Add static typing to functions and methods.](https://github.com/TheAlgorithms/Python/issues/2128)
  * [ ] [Set `flake8 --max-complexity=15`](https://github.com/TheAlgorithms/Python/issues/2128#issuecomment-645190839) (Ensure files have strong tests ___before___ refactoring).  Test results from #2139...
      * [ ] ./boolean_algebra/quine_mc_cluskey.py:82:1: C901 'selection' is too complex (17)
      * [ ] ./digital_image_processing/edge_detection/canny.py:20:1: C901 'canny' is too complex (17) @lighttxu
      * [ ] ./graphs/minimum_spanning_tree_prims.py:5:1: C901 'PrimsAlgorithm' is too complex (21)
          * [ ] Add doctests aligned with https://en.wikipedia.org/wiki/Prim%27s_algorithm
          * [ ] In a ___separate___ PR reduce the McCabe complexity
      * [ ] ./linear_algebra/src/polynom-for-points.py:1:1: C901 'points_to_polynomial' is too complex (23) @nic-dern
      * [ ] ./machine_learning/linear_discriminant_analysis.py:251:1: C901 'main' is too complex (25)
      * [x] ./hashes/hamming_code.py:71:1: C901 'emitterConverter' is too complex (16) #2140
      * [x] ./hashes/hamming_code.py:153:1: C901 'receptorConverter' is too complex (20) #2140
      * [x] ./project_euler/problem_551/sol1.py:20:1: C901 'next_term' is too complex (16) #2141
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `searches/simple_binary_search.py`
  Content:
  ```
  1 """
  2 Pure Python implementation of a binary search algorithm.
  3 
  4 For doctests run following command:
  5 python3 -m doctest -v simple_binary_search.py
  6 
  7 For manual testing run:
  8 python3 simple_binary_search.py
  9 """
  10 from __future__ import annotations
  11 
  12 
  13 def binary_search(a_list: list[int], item: int) -> bool:
  14     """
  15     >>> test_list = [0, 1, 2, 8, 13, 17, 19, 32, 42]
  16     >>> print(binary_search(test_list, 3))
  17     False
  18     >>> print(binary_search(test_list, 13))
  19     True
  20     >>> print(binary_search([4, 4, 5, 6, 7], 4))
  21     True
  22     >>> print(binary_search([4, 4, 5, 6, 7], -10))
  23     False
  24     >>> print(binary_search([-18, 2], -18))
  25     True
  26     >>> print(binary_search([5], 5))
  27     True
  28     >>> print(binary_search(['a', 'c', 'd'], 'c'))
  29     True
  30     >>> print(binary_search(['a', 'c', 'd'], 'f'))
  31     False
  32     >>> print(binary_search([], 1))
  33     False
  34     >>> print(binary_search([-.1, .1 , .8], .1))
  35     True
  36     >>> binary_search(range(-5000, 5000, 10), 80)
  37     True
  38     >>> binary_search(range(-5000, 5000, 10), 1255)
  39     False
  40     >>> binary_search(range(0, 10000, 5), 2)
  41     False
  42     """
  43     if len(a_list) == 0:
  44         return False
  45     midpoint = len(a_list) // 2
  46     if a_list[midpoint] == item:
  47         return True
  48     if item < a_list[midpoint]:
  49         return binary_search(a_list[:midpoint], item)
  50     else:
  51         return binary_search(a_list[midpoint + 1 :], item)
  52 
  53 
  54 if __name__ == "__main__":
  55     user_input = input("Enter numbers separated by comma:\n").strip()
  56     sequence = [int(item.strip()) for item in user_input.split(",")]
  57     target = int(input("Enter the number to be found in the list:\n").strip())
  58     not_str = "" if binary_search(sequence, target) else "not "
  59     print(f"{target} was {not_str}found in {sequence}")
  60
  ```
  
  Path: `graphs/minimum_spanning_tree_kruskal.py`
  Content:
  ```
  1 if __name__ == "__main__":
  2     num_nodes, num_edges = list(map(int, input().strip().split()))
  3 
  4     edges = []
  5 
  6     for i in range(num_edges):
  7         node1, node2, cost = list(map(int, input().strip().split()))
  8         edges.append((i, node1, node2, cost))
  9 
  10     edges = sorted(edges, key=lambda edge: edge[3])
  11 
  12     parent = list(range(num_nodes))
  13 
  14     def find_parent(i):
  15         if i != parent[i]:
  16             parent[i] = find_parent(parent[i])
  17         return parent[i]
  18 
  19     minimum_spanning_tree_cost = 0
  20     minimum_spanning_tree = []
  21 
  22     for edge in edges:
  23         parent_a = find_parent(edge[1])
  24         parent_b = find_parent(edge[2])
  25         if parent_a != parent_b:
  26             minimum_spanning_tree_cost += edge[3]
  27             minimum_spanning_tree.append(edge)
  28             parent[parent_a] = parent_b
  29 
  30     print(minimum_spanning_tree_cost)
  31     for edge in minimum_spanning_tree:
  32         print(edge)
  33
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/graphs/minimum_spanning_tree_kruskal.py b/graphs/minimum_spanning_tree_kruskal.py
  --- a/graphs/minimum_spanning_tree_kruskal.py
  +++ b/graphs/minimum_spanning_tree_kruskal.py
  @@ -1,13 +1,5 @@
  -if __name__ == "__main__":
  -    num_nodes, num_edges = list(map(int, input().strip().split()))
  -
  -    edges = []
  -
  -    for i in range(num_edges):
  -        node1, node2, cost = list(map(int, input().strip().split()))
  -        edges.append((i, node1, node2, cost))
  -
  -    edges = sorted(edges, key=lambda edge: edge[3])
  +def kruskal(num_nodes, num_edges, edges):
  +    edges = sorted(edges, key=lambda edge: edge[2])
   
       parent = list(range(num_nodes))
   
  @@ -20,13 +12,22 @@
       minimum_spanning_tree = []
   
       for edge in edges:
  -        parent_a = find_parent(edge[1])
  -        parent_b = find_parent(edge[2])
  +        parent_a = find_parent(edge[0])
  +        parent_b = find_parent(edge[1])
           if parent_a != parent_b:
  -            minimum_spanning_tree_cost += edge[3]
  +            minimum_spanning_tree_cost += edge[2]
               minimum_spanning_tree.append(edge)
               parent[parent_a] = parent_b
   
  -    print(minimum_spanning_tree_cost)
  -    for edge in minimum_spanning_tree:
  -        print(edge)
  +    return minimum_spanning_tree
  +
  +
  +if __name__ == "__main__":  # pragma: no cover
  +    num_nodes, num_edges = list(map(int, input().strip().split()))
  +    edges = []
  +
  +    for _ in range(num_edges):
  +        node1, node2, cost = [int(x) for x in input().strip().split()]
  +        edges.append((node1, node2, cost))
  +
  +    kruskal(num_nodes, num_edges, edges)
  diff --git a/searches/simple_binary_search.py b/searches/simple_binary_search.py
  --- a/searches/simple_binary_search.py
  +++ b/searches/simple_binary_search.py
  @@ -42,7 +42,7 @@
       if item < a_list[midpoint]:
           return binary_search(a_list[:midpoint], item)
       else:
  -        return binary_search(a_list[midpoint + 1:], item)
  +        return binary_search(a_list[midpoint + 1 :], item)
   
   
   if __name__ == "__main__":
  
verification_info: {"golden_diff": "diff --git a/graphs/minimum_spanning_tree_kruskal.py b/graphs/minimum_spanning_tree_kruskal.py\n--- a/graphs/minimum_spanning_tree_kruskal.py\n+++ b/graphs/minimum_spanning_tree_kruskal.py\n@@ -1,13 +1,5 @@\n-if __name__ == \"__main__\":\n-    num_nodes, num_edges = list(map(int, input().strip().split()))\n-\n-    edges = []\n-\n-    for i in range(num_edges):\n-        node1, node2, cost = list(map(int, input().strip().split()))\n-        edges.append((i, node1, node2, cost))\n-\n-    edges = sorted(edges, key=lambda edge: edge[3])\n+def kruskal(num_nodes, num_edges, edges):\n+    edges = sorted(edges, key=lambda edge: edge[2])\n \n     parent = list(range(num_nodes))\n \n@@ -20,13 +12,22 @@\n     minimum_spanning_tree = []\n \n     for edge in edges:\n-        parent_a = find_parent(edge[1])\n-        parent_b = find_parent(edge[2])\n+        parent_a = find_parent(edge[0])\n+        parent_b = find_parent(edge[1])\n         if parent_a != parent_b:\n-            minimum_spanning_tree_cost += edge[3]\n+            minimum_spanning_tree_cost += edge[2]\n             minimum_spanning_tree.append(edge)\n             parent[parent_a] = parent_b\n \n-    print(minimum_spanning_tree_cost)\n-    for edge in minimum_spanning_tree:\n-        print(edge)\n+    return minimum_spanning_tree\n+\n+\n+if __name__ == \"__main__\":  # pragma: no cover\n+    num_nodes, num_edges = list(map(int, input().strip().split()))\n+    edges = []\n+\n+    for _ in range(num_edges):\n+        node1, node2, cost = [int(x) for x in input().strip().split()]\n+        edges.append((node1, node2, cost))\n+\n+    kruskal(num_nodes, num_edges, edges)\ndiff --git a/searches/simple_binary_search.py b/searches/simple_binary_search.py\n--- a/searches/simple_binary_search.py\n+++ b/searches/simple_binary_search.py\n@@ -42,7 +42,7 @@\n     if item < a_list[midpoint]:\n         return binary_search(a_list[:midpoint], item)\n     else:\n-        return binary_search(a_list[midpoint + 1:], item)\n+        return binary_search(a_list[midpoint + 1 :], item)\n \n \n if __name__ == \"__main__\":\n", "issue": "Dev sprint ideas: More tests, type hints and less complexity\ncurrently, some of the programs use static type checking like this [program](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/fast_fibonacci.py) but some of the programs did not use static typing.\r\n\r\nit's a good practice to use static typing as it makes code more clear and readable, should we make it a standard for this repository.we can use [mypy](http://mypy-lang.org/) for testing code \r\n\r\n[more on static typing](https://medium.com/@ageitgey/learn-how-to-use-static-type-checking-in-python-3-6-in-10-minutes-12c86d72677b)\r\n \r\nthank you\r\n\r\n### Dev sprint ideas:\r\n* [ ] [Add tests to Python files with <10% test coverage.](https://github.com/TheAlgorithms/Python/issues/2128#issuecomment-645231020)\r\n* [ ] [Add static typing to functions and methods.](https://github.com/TheAlgorithms/Python/issues/2128)\r\n* [ ] [Set `flake8 --max-complexity=15`](https://github.com/TheAlgorithms/Python/issues/2128#issuecomment-645190839) (Ensure files have strong tests ___before___ refactoring).  Test results from #2139...\r\n    * [ ] ./boolean_algebra/quine_mc_cluskey.py:82:1: C901 'selection' is too complex (17)\r\n    * [ ] ./digital_image_processing/edge_detection/canny.py:20:1: C901 'canny' is too complex (17) @lighttxu\r\n    * [ ] ./graphs/minimum_spanning_tree_prims.py:5:1: C901 'PrimsAlgorithm' is too complex (21)\r\n        * [ ] Add doctests aligned with https://en.wikipedia.org/wiki/Prim%27s_algorithm\r\n        * [ ] In a ___separate___ PR reduce the McCabe complexity\r\n    * [ ] ./linear_algebra/src/polynom-for-points.py:1:1: C901 'points_to_polynomial' is too complex (23) @nic-dern\r\n    * [ ] ./machine_learning/linear_discriminant_analysis.py:251:1: C901 'main' is too complex (25)\r\n    * [x] ./hashes/hamming_code.py:71:1: C901 'emitterConverter' is too complex (16) #2140\r\n    * [x] ./hashes/hamming_code.py:153:1: C901 'receptorConverter' is too complex (20) #2140\r\n    * [x] ./project_euler/problem_551/sol1.py:20:1: C901 'next_term' is too complex (16) #2141\n", "before_files": [{"content": "\"\"\"\nPure Python implementation of a binary search algorithm.\n\nFor doctests run following command:\npython3 -m doctest -v simple_binary_search.py\n\nFor manual testing run:\npython3 simple_binary_search.py\n\"\"\"\nfrom __future__ import annotations\n\n\ndef binary_search(a_list: list[int], item: int) -> bool:\n    \"\"\"\n    >>> test_list = [0, 1, 2, 8, 13, 17, 19, 32, 42]\n    >>> print(binary_search(test_list, 3))\n    False\n    >>> print(binary_search(test_list, 13))\n    True\n    >>> print(binary_search([4, 4, 5, 6, 7], 4))\n    True\n    >>> print(binary_search([4, 4, 5, 6, 7], -10))\n    False\n    >>> print(binary_search([-18, 2], -18))\n    True\n    >>> print(binary_search([5], 5))\n    True\n    >>> print(binary_search(['a', 'c', 'd'], 'c'))\n    True\n    >>> print(binary_search(['a', 'c', 'd'], 'f'))\n    False\n    >>> print(binary_search([], 1))\n    False\n    >>> print(binary_search([-.1, .1 , .8], .1))\n    True\n    >>> binary_search(range(-5000, 5000, 10), 80)\n    True\n    >>> binary_search(range(-5000, 5000, 10), 1255)\n    False\n    >>> binary_search(range(0, 10000, 5), 2)\n    False\n    \"\"\"\n    if len(a_list) == 0:\n        return False\n    midpoint = len(a_list) // 2\n    if a_list[midpoint] == item:\n        return True\n    if item < a_list[midpoint]:\n        return binary_search(a_list[:midpoint], item)\n    else:\n        return binary_search(a_list[midpoint + 1 :], item)\n\n\nif __name__ == \"__main__\":\n    user_input = input(\"Enter numbers separated by comma:\\n\").strip()\n    sequence = [int(item.strip()) for item in user_input.split(\",\")]\n    target = int(input(\"Enter the number to be found in the list:\\n\").strip())\n    not_str = \"\" if binary_search(sequence, target) else \"not \"\n    print(f\"{target} was {not_str}found in {sequence}\")\n", "path": "searches/simple_binary_search.py"}, {"content": "if __name__ == \"__main__\":\n    num_nodes, num_edges = list(map(int, input().strip().split()))\n\n    edges = []\n\n    for i in range(num_edges):\n        node1, node2, cost = list(map(int, input().strip().split()))\n        edges.append((i, node1, node2, cost))\n\n    edges = sorted(edges, key=lambda edge: edge[3])\n\n    parent = list(range(num_nodes))\n\n    def find_parent(i):\n        if i != parent[i]:\n            parent[i] = find_parent(parent[i])\n        return parent[i]\n\n    minimum_spanning_tree_cost = 0\n    minimum_spanning_tree = []\n\n    for edge in edges:\n        parent_a = find_parent(edge[1])\n        parent_b = find_parent(edge[2])\n        if parent_a != parent_b:\n            minimum_spanning_tree_cost += edge[3]\n            minimum_spanning_tree.append(edge)\n            parent[parent_a] = parent_b\n\n    print(minimum_spanning_tree_cost)\n    for edge in minimum_spanning_tree:\n        print(edge)\n", "path": "graphs/minimum_spanning_tree_kruskal.py"}], "after_files": [{"content": "\"\"\"\nPure Python implementation of a binary search algorithm.\n\nFor doctests run following command:\npython3 -m doctest -v simple_binary_search.py\n\nFor manual testing run:\npython3 simple_binary_search.py\n\"\"\"\nfrom typing import List\n\n\ndef binary_search(a_list: List[int], item: int) -> bool:\n    \"\"\"\n    >>> test_list = [0, 1, 2, 8, 13, 17, 19, 32, 42]\n    >>> print(binary_search(test_list, 3))\n    False\n    >>> print(binary_search(test_list, 13))\n    True\n    >>> print(binary_search([4, 4, 5, 6, 7], 4))\n    True\n    >>> print(binary_search([4, 4, 5, 6, 7], -10))\n    False\n    >>> print(binary_search([-18, 2], -18))\n    True\n    >>> print(binary_search([5], 5))\n    True\n    >>> print(binary_search(['a', 'c', 'd'], 'c'))\n    True\n    >>> print(binary_search(['a', 'c', 'd'], 'f'))\n    False\n    >>> print(binary_search([], 1))\n    False\n    >>> print(binary_search([.1, .4 , -.1], .1))\n    True\n    \"\"\"\n    if len(a_list) == 0:\n        return False\n    midpoint = len(a_list) // 2\n    if a_list[midpoint] == item:\n        return True\n    if item < a_list[midpoint]:\n        return binary_search(a_list[:midpoint], item)\n    else:\n        return binary_search(a_list[midpoint + 1 :], item)\n\n\nif __name__ == \"__main__\":\n    user_input = input(\"Enter numbers separated by comma:\\n\").strip()\n    sequence = [int(item.strip()) for item in user_input.split(\",\")]\n    target = int(input(\"Enter the number to be found in the list:\\n\").strip())\n    not_str = \"\" if binary_search(sequence, target) else \"not \"\n    print(f\"{target} was {not_str}found in {sequence}\")\n", "path": "searches/simple_binary_search.py"}, {"content": "def kruskal(num_nodes, num_edges, edges):\n    edges = sorted(edges, key=lambda edge: edge[2])\n\n    parent = list(range(num_nodes))\n\n    def find_parent(i):\n        if i != parent[i]:\n            parent[i] = find_parent(parent[i])\n        return parent[i]\n\n    minimum_spanning_tree_cost = 0\n    minimum_spanning_tree = []\n\n    for edge in edges:\n        parent_a = find_parent(edge[0])\n        parent_b = find_parent(edge[1])\n        if parent_a != parent_b:\n            minimum_spanning_tree_cost += edge[2]\n            minimum_spanning_tree.append(edge)\n            parent[parent_a] = parent_b\n\n    return minimum_spanning_tree\n\n\nif __name__ == \"__main__\":  # pragma: no cover\n    num_nodes, num_edges = list(map(int, input().strip().split()))\n    edges = []\n\n    for _ in range(num_edges):\n        node1, node2, cost = [int(x) for x in input().strip().split()]\n        edges.append((node1, node2, cost))\n\n    kruskal(num_nodes, num_edges, edges)\n", "path": "graphs/minimum_spanning_tree_kruskal.py"}]}