Reformatted code base using black.

This commit is contained in:
Goffi 2024-06-19 18:44:57 +02:00
commit 53fdaa9d09

View file

@ -30,12 +30,14 @@ log = getLogger(__name__)
def async_lru(maxsize: Optional[int] = 50) -> Callable:
"""Decorator to cache async function results using LRU algorithm
@param maxsize: maximum number of items to keep in cache.
None to have no limit
@param maxsize: maximum number of items to keep in cache.
None to have no limit
"""
def decorator(func: Callable) -> Callable:
cache = OrderedDict()
async def wrapper(*args) -> Awaitable:
if args in cache:
log.debug(f"using result in cache for {args}")
@ -49,5 +51,7 @@ def async_lru(maxsize: Optional[int] = 50) -> Callable:
value = cache.popitem(False)
log.debug(f"Removing LRU value: {value}")
return result
return wrapper
return decorator