We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[mypy] Need help to fix all `mypy` errors in the codebase
# Just one left to fix...
https://github.com/TheAlgorithms/Python/blob/master/mypy.ini#L5
* [x] other/least_recently_used.py
* [x] other/lfu_cache.py #5755
* [x] other/lru_cache.py #5755

---

__UPDATE:__ Our GitHub Actions now run `mypy --ignore-missing-imports` excluding those directories that fail that test.
* https://github.com/TheAlgorithms/Python/blob/master/mypy.ini#L5

Currently, we are not running `mypy` in our regular CI tests as there are a lot of errors in the entire codebase, which needs to be fixed. This won't be a one-person job, so we are asking for help from you. I cannot paste the entire message in here as there are around 600 of them, so here's just a gist of it:

```console
$ mypy --ignore-missing-imports .
strings/word_occurrence.py:17: error: Need type annotation for 'occurrence'
strings/min_cost_string_conversion.py:36: error: No overload variant of "__setitem__" of "list" matches argument types "int", "str"
strings/min_cost_string_conversion.py:36: note: Possible overload variants:
strings/min_cost_string_conversion.py:36: note:     def __setitem__(self, int, int) -> None
strings/min_cost_string_conversion.py:36: note:     def __setitem__(self, slice, Iterable[int]) -> None
strings/min_cost_string_conversion.py:40: error: No overload variant of "__setitem__" of "list" matches argument types "int", "str"
strings/min_cost_string_conversion.py:40: note: Possible overload variants:
strings/min_cost_string_conversion.py:40: note:     def __setitem__(self, int, int) -> None
strings/min_cost_string_conversion.py:40: note:     def __setitem__(self, slice, Iterable[int]) -> None
...
backtracking/n_queens_math.py:109: error: List comprehension has incompatible type List[str]; expected List[int]
backtracking/n_queens_math.py:110: error: Argument 1 to "append" of "list" has incompatible type "List[int]"; expected "List[str]"
backtracking/n_queens_math.py:149: error: Need type annotation for 'boards' (hint: "boards: List[<type>] = ...")
backtracking/minimax.py:15: error: "list" is not subscriptable, use "typing.List" instead
backtracking/knight_tour.py:6: error: "tuple" is not subscriptable, use "typing.Tuple" instead
backtracking/knight_tour.py:6: error: "list" is not subscriptable, use "typing.List" instead
...
```

# Guidelines to follow:

- Please make sure you read the [Contributing Guidelines](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md) first.
- Please submit a fix for a maximum of 3 files at a time (1 file is also acceptable).
- As we are not running `mypy` in our CI tests, the user who is submitting a pull request should run it on their local machine and ensure there are no errors in their submission.
- Please ensure your pull request title contains the word `mypy` in it. If possible use this template for your pull request title:
```
[mypy] Fix type annotations for <filenames>
```

### Which errors to fix?

Please follow the below steps to produce all the errors in this library:
- Fork this repository if you haven't already.
- Clone the forked repository on your local machine using the command:

```
git clone --depth 1 https://github.com/TheAlgorithms/Python.git
```
Then you need to install all the necessary requirements:
```
cd python/
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install mypy
```
Then run either of the two commands:
- `mypy --ignore-missing-imports .` -> To produce all the error messages for the entire codebase.
- `mypy --ignore-missing-imports <filepath1> <filepath2> ...` -> To produce error messages for the mentioned file.

### How to fix the errors?

- Make a separate branch for your fix with the command: 
```
git checkout -b mypy-fix
```
- Make changes to the selected files.
- Push it to your forked copy and open a pull request with the appropriate title as mentioned above.

### Focus on one directory at a time:

```
.
├── [x] arithmetic_analysis
├── [x] backtracking
├── [x] bit_manipulation
├── [x] blockchain
├── [x] boolean_algebra
├── [x] cellular_automata
├── [x] ciphers
├── [x] compression
├── [x] computer_vision
├── [x] conversions
├── [ ] data_structures
├── [x] digital_image_processing
├── [x] divide_and_conquer
├── [ ] dynamic_programming
├── [x] electronics
├── [x] file_transfer
├── [x] fractals
├── [x] fuzzy_logic
├── [x] genetic_algorithm
├── [x] geodesy
├── [x] graphics
├── [ ] graphs
├── [x] hashes
├── [x] knapsack
├── [x] linear_algebra
├── [x] machine_learning
├── [ ] maths
├── [ ] matrix
├── [x] networking_flow
├── [x] neural_network
├── [ ] other
├── [ ] project_euler
├── [x] quantum
├── [x] scheduling
├── [x] scripts
├── [ ] searches
├── [x] sorts
├── [ ] strings
└── [x] web_programming
```

### Pre-requisites:
- You should be familiar with `mypy`: https://mypy.readthedocs.io
- You should be familiar with Python type hints: https://docs.python.org/3/library/typing.html

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `other/least_recently_used.py`
Content:
```
1 import sys
2 from abc import abstractmethod
3 from collections import deque
4 
5 
6 class LRUCache:
7     """Page Replacement Algorithm, Least Recently Used (LRU) Caching."""
8 
9     dq_store = object()  # Cache store of keys
10     key_reference_map = object()  # References of the keys in cache
11     _MAX_CAPACITY: int = 10  # Maximum capacity of cache
12 
13     @abstractmethod
14     def __init__(self, n: int):
15         """Creates an empty store and map for the keys.
16         The LRUCache is set the size n.
17         """
18         self.dq_store = deque()
19         self.key_reference_map = set()
20         if not n:
21             LRUCache._MAX_CAPACITY = sys.maxsize
22         elif n < 0:
23             raise ValueError("n should be an integer greater than 0.")
24         else:
25             LRUCache._MAX_CAPACITY = n
26 
27     def refer(self, x):
28         """
29         Looks for a page in the cache store and adds reference to the set.
30         Remove the least recently used key if the store is full.
31         Update store to reflect recent access.
32         """
33         if x not in self.key_reference_map:
34             if len(self.dq_store) == LRUCache._MAX_CAPACITY:
35                 last_element = self.dq_store.pop()
36                 self.key_reference_map.remove(last_element)
37         else:
38             index_remove = 0
39             for idx, key in enumerate(self.dq_store):
40                 if key == x:
41                     index_remove = idx
42                     break
43             self.dq_store.remove(index_remove)
44 
45         self.dq_store.appendleft(x)
46         self.key_reference_map.add(x)
47 
48     def display(self):
49         """
50         Prints all the elements in the store.
51         """
52         for k in self.dq_store:
53             print(k)
54 
55 
56 if __name__ == "__main__":
57     lru_cache = LRUCache(4)
58     lru_cache.refer(1)
59     lru_cache.refer(2)
60     lru_cache.refer(3)
61     lru_cache.refer(1)
62     lru_cache.refer(4)
63     lru_cache.refer(5)
64     lru_cache.display()
65
```
--- 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()

```

diff --git a/other/least_recently_used.py b/other/least_recently_used.py
--- a/other/least_recently_used.py
+++ b/other/least_recently_used.py
@@ -1,5 +1,4 @@
 import sys
-from abc import abstractmethod
 from collections import deque
 
 
@@ -10,7 +9,6 @@
     key_reference_map = object()  # References of the keys in cache
     _MAX_CAPACITY: int = 10  # Maximum capacity of cache
 
-    @abstractmethod
     def __init__(self, n: int):
         """Creates an empty store and map for the keys.
         The LRUCache is set the size n.

{"golden_diff": "diff --git a/other/least_recently_used.py b/other/least_recently_used.py\n--- a/other/least_recently_used.py\n+++ b/other/least_recently_used.py\n@@ -1,5 +1,4 @@\n import sys\n-from abc import abstractmethod\n from collections import deque\n \n \n@@ -10,7 +9,6 @@\n     key_reference_map = object()  # References of the keys in cache\n     _MAX_CAPACITY: int = 10  # Maximum capacity of cache\n \n-    @abstractmethod\n     def __init__(self, n: int):\n         \"\"\"Creates an empty store and map for the keys.\n         The LRUCache is set the size n.\n", "issue": "[mypy] Need help to fix all `mypy` errors in the codebase\n# Just one left to fix...\r\nhttps://github.com/TheAlgorithms/Python/blob/master/mypy.ini#L5\r\n* [x] other/least_recently_used.py\r\n* [x] other/lfu_cache.py #5755\r\n* [x] other/lru_cache.py #5755\r\n\r\n---\r\n\r\n__UPDATE:__ Our GitHub Actions now run `mypy --ignore-missing-imports` excluding those directories that fail that test.\r\n* https://github.com/TheAlgorithms/Python/blob/master/mypy.ini#L5\r\n\r\nCurrently, we are not running `mypy` in our regular CI tests as there are a lot of errors in the entire codebase, which needs to be fixed. This won't be a one-person job, so we are asking for help from you. I cannot paste the entire message in here as there are around 600 of them, so here's just a gist of it:\r\n\r\n```console\r\n$ mypy --ignore-missing-imports .\r\nstrings/word_occurrence.py:17: error: Need type annotation for 'occurrence'\r\nstrings/min_cost_string_conversion.py:36: error: No overload variant of \"__setitem__\" of \"list\" matches argument types \"int\", \"str\"\r\nstrings/min_cost_string_conversion.py:36: note: Possible overload variants:\r\nstrings/min_cost_string_conversion.py:36: note:     def __setitem__(self, int, int) -> None\r\nstrings/min_cost_string_conversion.py:36: note:     def __setitem__(self, slice, Iterable[int]) -> None\r\nstrings/min_cost_string_conversion.py:40: error: No overload variant of \"__setitem__\" of \"list\" matches argument types \"int\", \"str\"\r\nstrings/min_cost_string_conversion.py:40: note: Possible overload variants:\r\nstrings/min_cost_string_conversion.py:40: note:     def __setitem__(self, int, int) -> None\r\nstrings/min_cost_string_conversion.py:40: note:     def __setitem__(self, slice, Iterable[int]) -> None\r\n...\r\nbacktracking/n_queens_math.py:109: error: List comprehension has incompatible type List[str]; expected List[int]\r\nbacktracking/n_queens_math.py:110: error: Argument 1 to \"append\" of \"list\" has incompatible type \"List[int]\"; expected \"List[str]\"\r\nbacktracking/n_queens_math.py:149: error: Need type annotation for 'boards' (hint: \"boards: List[<type>] = ...\")\r\nbacktracking/minimax.py:15: error: \"list\" is not subscriptable, use \"typing.List\" instead\r\nbacktracking/knight_tour.py:6: error: \"tuple\" is not subscriptable, use \"typing.Tuple\" instead\r\nbacktracking/knight_tour.py:6: error: \"list\" is not subscriptable, use \"typing.List\" instead\r\n...\r\n```\r\n\r\n# Guidelines to follow:\r\n\r\n- Please make sure you read the [Contributing Guidelines](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md) first.\r\n- Please submit a fix for a maximum of 3 files at a time (1 file is also acceptable).\r\n- As we are not running `mypy` in our CI tests, the user who is submitting a pull request should run it on their local machine and ensure there are no errors in their submission.\r\n- Please ensure your pull request title contains the word `mypy` in it. If possible use this template for your pull request title:\r\n```\r\n[mypy] Fix type annotations for <filenames>\r\n```\r\n\r\n### Which errors to fix?\r\n\r\nPlease follow the below steps to produce all the errors in this library:\r\n- Fork this repository if you haven't already.\r\n- Clone the forked repository on your local machine using the command:\r\n\r\n```\r\ngit clone --depth 1 https://github.com/TheAlgorithms/Python.git\r\n```\r\nThen you need to install all the necessary requirements:\r\n```\r\ncd python/\r\npython -m pip install --upgrade pip\r\npython -m pip install -r requirements.txt\r\npython -m pip install mypy\r\n```\r\nThen run either of the two commands:\r\n- `mypy --ignore-missing-imports .` -> To produce all the error messages for the entire codebase.\r\n- `mypy --ignore-missing-imports <filepath1> <filepath2> ...` -> To produce error messages for the mentioned file.\r\n\r\n### How to fix the errors?\r\n\r\n- Make a separate branch for your fix with the command: \r\n```\r\ngit checkout -b mypy-fix\r\n```\r\n- Make changes to the selected files.\r\n- Push it to your forked copy and open a pull request with the appropriate title as mentioned above.\r\n\r\n### Focus on one directory at a time:\r\n\r\n```\r\n.\r\n\u251c\u2500\u2500 [x] arithmetic_analysis\r\n\u251c\u2500\u2500 [x] backtracking\r\n\u251c\u2500\u2500 [x] bit_manipulation\r\n\u251c\u2500\u2500 [x] blockchain\r\n\u251c\u2500\u2500 [x] boolean_algebra\r\n\u251c\u2500\u2500 [x] cellular_automata\r\n\u251c\u2500\u2500 [x] ciphers\r\n\u251c\u2500\u2500 [x] compression\r\n\u251c\u2500\u2500 [x] computer_vision\r\n\u251c\u2500\u2500 [x] conversions\r\n\u251c\u2500\u2500 [ ] data_structures\r\n\u251c\u2500\u2500 [x] digital_image_processing\r\n\u251c\u2500\u2500 [x] divide_and_conquer\r\n\u251c\u2500\u2500 [ ] dynamic_programming\r\n\u251c\u2500\u2500 [x] electronics\r\n\u251c\u2500\u2500 [x] file_transfer\r\n\u251c\u2500\u2500 [x] fractals\r\n\u251c\u2500\u2500 [x] fuzzy_logic\r\n\u251c\u2500\u2500 [x] genetic_algorithm\r\n\u251c\u2500\u2500 [x] geodesy\r\n\u251c\u2500\u2500 [x] graphics\r\n\u251c\u2500\u2500 [ ] graphs\r\n\u251c\u2500\u2500 [x] hashes\r\n\u251c\u2500\u2500 [x] knapsack\r\n\u251c\u2500\u2500 [x] linear_algebra\r\n\u251c\u2500\u2500 [x] machine_learning\r\n\u251c\u2500\u2500 [ ] maths\r\n\u251c\u2500\u2500 [ ] matrix\r\n\u251c\u2500\u2500 [x] networking_flow\r\n\u251c\u2500\u2500 [x] neural_network\r\n\u251c\u2500\u2500 [ ] other\r\n\u251c\u2500\u2500 [ ] project_euler\r\n\u251c\u2500\u2500 [x] quantum\r\n\u251c\u2500\u2500 [x] scheduling\r\n\u251c\u2500\u2500 [x] scripts\r\n\u251c\u2500\u2500 [ ] searches\r\n\u251c\u2500\u2500 [x] sorts\r\n\u251c\u2500\u2500 [ ] strings\r\n\u2514\u2500\u2500 [x] web_programming\r\n```\r\n\r\n### Pre-requisites:\r\n- You should be familiar with `mypy`: https://mypy.readthedocs.io\r\n- You should be familiar with Python type hints: https://docs.python.org/3/library/typing.html\n", "before_files": [{"content": "import sys\nfrom abc import abstractmethod\nfrom collections import deque\n\n\nclass LRUCache:\n    \"\"\"Page Replacement Algorithm, Least Recently Used (LRU) Caching.\"\"\"\n\n    dq_store = object()  # Cache store of keys\n    key_reference_map = object()  # References of the keys in cache\n    _MAX_CAPACITY: int = 10  # Maximum capacity of cache\n\n    @abstractmethod\n    def __init__(self, n: int):\n        \"\"\"Creates an empty store and map for the keys.\n        The LRUCache is set the size n.\n        \"\"\"\n        self.dq_store = deque()\n        self.key_reference_map = set()\n        if not n:\n            LRUCache._MAX_CAPACITY = sys.maxsize\n        elif n < 0:\n            raise ValueError(\"n should be an integer greater than 0.\")\n        else:\n            LRUCache._MAX_CAPACITY = n\n\n    def refer(self, x):\n        \"\"\"\n        Looks for a page in the cache store and adds reference to the set.\n        Remove the least recently used key if the store is full.\n        Update store to reflect recent access.\n        \"\"\"\n        if x not in self.key_reference_map:\n            if len(self.dq_store) == LRUCache._MAX_CAPACITY:\n                last_element = self.dq_store.pop()\n                self.key_reference_map.remove(last_element)\n        else:\n            index_remove = 0\n            for idx, key in enumerate(self.dq_store):\n                if key == x:\n                    index_remove = idx\n                    break\n            self.dq_store.remove(index_remove)\n\n        self.dq_store.appendleft(x)\n        self.key_reference_map.add(x)\n\n    def display(self):\n        \"\"\"\n        Prints all the elements in the store.\n        \"\"\"\n        for k in self.dq_store:\n            print(k)\n\n\nif __name__ == \"__main__\":\n    lru_cache = LRUCache(4)\n    lru_cache.refer(1)\n    lru_cache.refer(2)\n    lru_cache.refer(3)\n    lru_cache.refer(1)\n    lru_cache.refer(4)\n    lru_cache.refer(5)\n    lru_cache.display()\n", "path": "other/least_recently_used.py"}], "after_files": [{"content": "import sys\nfrom collections import deque\n\n\nclass LRUCache:\n    \"\"\"Page Replacement Algorithm, Least Recently Used (LRU) Caching.\"\"\"\n\n    dq_store = object()  # Cache store of keys\n    key_reference_map = object()  # References of the keys in cache\n    _MAX_CAPACITY: int = 10  # Maximum capacity of cache\n\n    def __init__(self, n: int):\n        \"\"\"Creates an empty store and map for the keys.\n        The LRUCache is set the size n.\n        \"\"\"\n        self.dq_store = deque()\n        self.key_reference_map = set()\n        if not n:\n            LRUCache._MAX_CAPACITY = sys.maxsize\n        elif n < 0:\n            raise ValueError(\"n should be an integer greater than 0.\")\n        else:\n            LRUCache._MAX_CAPACITY = n\n\n    def refer(self, x):\n        \"\"\"\n        Looks for a page in the cache store and adds reference to the set.\n        Remove the least recently used key if the store is full.\n        Update store to reflect recent access.\n        \"\"\"\n        if x not in self.key_reference_map:\n            if len(self.dq_store) == LRUCache._MAX_CAPACITY:\n                last_element = self.dq_store.pop()\n                self.key_reference_map.remove(last_element)\n        else:\n            index_remove = 0\n            for idx, key in enumerate(self.dq_store):\n                if key == x:\n                    index_remove = idx\n                    break\n            self.dq_store.remove(index_remove)\n\n        self.dq_store.appendleft(x)\n        self.key_reference_map.add(x)\n\n    def display(self):\n        \"\"\"\n        Prints all the elements in the store.\n        \"\"\"\n        for k in self.dq_store:\n            print(k)\n\n\nif __name__ == \"__main__\":\n    lru_cache = LRUCache(4)\n    lru_cache.refer(1)\n    lru_cache.refer(2)\n    lru_cache.refer(3)\n    lru_cache.refer(1)\n    lru_cache.refer(4)\n    lru_cache.refer(5)\n    lru_cache.display()\n", "path": "other/least_recently_used.py"}]}