Skip to content

Commit 158128c

Browse files
authored
Update lru_cache.py
1 parent 97b33b2 commit 158128c

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

other/lru_cache.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
from __future__ import annotations
22

33
from collections.abc import Callable
4-
from typing import Generic, TypeVar
54

6-
T = TypeVar("T")
7-
U = TypeVar("U")
85

9-
10-
class DoubleLinkedListNode(Generic[T, U]):
6+
class DoubleLinkedListNode[T, U]:
117
"""
128
Double Linked List Node built specifically for LRU Cache
139
@@ -28,7 +24,7 @@ def __repr__(self) -> str:
2824
)
2925

3026

31-
class DoubleLinkedList(Generic[T, U]):
27+
class DoubleLinkedList[T, U]:
3228
"""
3329
Double Linked List built specifically for LRU Cache
3430
@@ -143,7 +139,7 @@ def remove(
143139
return node
144140

145141

146-
class LRUCache(Generic[T, U]):
142+
class LRUCache[T, U]:
147143
"""
148144
LRU Cache to store a given capacity of data. Can be used as a stand-alone object
149145
or as a function decorator.
@@ -227,8 +223,7 @@ def __repr__(self) -> str:
227223
f"CacheInfo(hits={self.hits}, misses={self.miss}, "
228224
f"capacity={self.capacity}, current size={self.num_keys})"
229225
)
230-
231-
def __contains__(self, key: T) -> bool:
226+
def __contains__(self, key: T) -> bool:
232227
"""
233228
>>> cache = LRUCache(1)
234229

0 commit comments

Comments
 (0)