From 0e3cdfa5d2feee6ca4ac6aad08bb63e4fd96bdc5 Mon Sep 17 00:00:00 2001 From: GigantPro Date: Wed, 30 Aug 2023 14:45:20 +0300 Subject: [PATCH] Fix linting --- frozenclass/cache.py | 8 ++++---- tests/test_async_cache.py | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/frozenclass/cache.py b/frozenclass/cache.py index 1879ea6..1006651 100644 --- a/frozenclass/cache.py +++ b/frozenclass/cache.py @@ -11,6 +11,8 @@ def cache(*, ttl: Optional[time] = time(minute=10), :param ttl: Time-To-Live of cached valume, defaults to time(minute=10) :type ttl: time | None, optional + :param is_async: Set True if decorated func is async, defaults to False + :type is_async: bool, optional :return: Decorated func :rtype: Callable """ @@ -37,7 +39,7 @@ def cached_func_without_time(*args, **kwargs) -> Any: result = target_func(*args, **kwargs) __cached_vals[(*args, *kwargs)] = result return result - + async def async_cached_func_with_time(*args, **kwargs) -> Any: cached_ = __cached_vals.get((*args, *kwargs), None) @@ -63,8 +65,6 @@ async def async_cached_func_without_time(*args, **kwargs) -> Any: if not is_async: return cached_func_with_time if ttl else cached_func_without_time - - else: - return async_cached_func_with_time if ttl else async_cached_func_without_time + return async_cached_func_with_time if ttl else async_cached_func_without_time return wrapper_func diff --git a/tests/test_async_cache.py b/tests/test_async_cache.py index 105cc76..e5383b7 100644 --- a/tests/test_async_cache.py +++ b/tests/test_async_cache.py @@ -1,7 +1,5 @@ -import sqlite3 from datetime import time -from time import sleep, time as t_time -from timeit import timeit +from time import sleep import pytest from frozenclass import CacheController