@@ -61,12 +61,13 @@ def __repr__(self) -> str:
6161 node = node .next
6262 rep .append (str (self .rear ))
6363 return ",\n " .join (rep )
64+
6465 def add (self , node : DoubleLinkedListNode [T , U ]) -> None :
6566 """Adds the given node to the end of the list (before rear)"""
6667 previous = self .rear .prev
6768 if previous is None :
6869 raise ValueError ("Invalid list state: rear.prev is None" )
69-
70+
7071 previous .next = node
7172 node .prev = previous
7273 self .rear .prev = node
@@ -148,15 +149,11 @@ def put(self, key: T, value: U) -> None:
148149 @classmethod
149150 def decorator (
150151 cls , size : int = 128
151- ) -> Callable [[Callable [P , R ]], Callable [P , R ]]:
152- ...
153-
152+ ) -> Callable [[Callable [P , R ]], Callable [P , R ]]: ...
153+
154154 @overload
155155 @classmethod
156- def decorator (
157- cls , func : Callable [P , R ]
158- ) -> Callable [P , R ]:
159- ...
156+ def decorator (cls , func : Callable [P , R ]) -> Callable [P , R ]: ...
160157
161158 @classmethod
162159 def decorator (
@@ -166,7 +163,7 @@ def decorator(
166163 if callable (size ):
167164 # Called without parentheses (@LRUCache.decorator)
168165 return cls .decorator ()(size )
169-
166+
170167 def decorator_func (func : Callable [P , R ]) -> Callable [P , R ]:
171168 cache_instance = cls [Any , R ](size ) # type: ignore[valid-type]
172169
@@ -180,6 +177,7 @@ def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
180177 result = func (* args , ** kwargs )
181178 cache_instance .put (key , result )
182179 return result
180+
183181 def cache_info () -> LRUCache [Any , R ]: # type: ignore[valid-type]
184182 return cache_instance
185183
@@ -191,4 +189,5 @@ def cache_info() -> LRUCache[Any, R]: # type: ignore[valid-type]
191189
192190if __name__ == "__main__" :
193191 import doctest
192+
194193 doctest .testmod ()
0 commit comments