From f9f7862be0a3dfe8d9f7f3e5107e33f55b7d7b01 Mon Sep 17 00:00:00 2001 From: Vadym Sulim Date: Thu, 3 Oct 2024 10:20:59 +0300 Subject: [PATCH] fixed linter errors --- app/main.py | 2 ++ tests/test_main.py | 20 +++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/main.py b/app/main.py index 985d6c0d..e8853428 100644 --- a/app/main.py +++ b/app/main.py @@ -1,5 +1,6 @@ from typing import Callable, Any + def cache(func: Callable) -> Callable: storage = {} @@ -12,4 +13,5 @@ def wrapper(*args, **kwargs) -> Any: result = func(*args, **kwargs) storage[args] = result return result + return wrapper diff --git a/tests/test_main.py b/tests/test_main.py index 37d969c6..96b03723 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -9,7 +9,7 @@ def test_cache_single_function(): @cache def long_time_func(a, b, c): - return (a ** b ** c) % (a * c) + return (a**b**c) % (a * c) f = io.StringIO() @@ -31,7 +31,7 @@ def long_time_func(a, b, c): ) assert ( - out == output + out == output ), f""" output must be: {output}, @@ -48,7 +48,7 @@ def long_time_func(a, b, c): def test_cache_multiple_functions(): @cache def long_time_func(a, b, c): - return (a ** b ** c) % (a * c) + return (a**b**c) % (a * c) @cache def long_time_func_2(text_1, text_2): @@ -113,7 +113,7 @@ def long_time_func_3(n_list, text): def test_cache_returns_correct_value(): @cache def long_time_func(a, b, c): - return (a ** b ** c) % (a * c) + return (a**b**c) % (a * c) first_value = long_time_func(2, 3, 3) second_value = long_time_func(2, 3, 3) @@ -148,9 +148,7 @@ def addition(a, b): "Getting from cache\n" ) - assert ( - out == output - ), "Cache decorator should depend on different function" + assert out == output, "Cache decorator should depend on different function" def test_deco_returns_cached_value(): @@ -165,9 +163,9 @@ def delay_addition(a, b): delay_addition(1, 2) time3 = time.time() - assert 3 <= time2 - time1 < 4, ( - "Cache decorator should work once to calculate the result" - ) + assert ( + 3 <= time2 - time1 < 4 + ), "Cache decorator should work once to calculate the result" assert time3 - time2 < 1, "Cache decorator should return cached value." @@ -181,5 +179,5 @@ def test_unnecessary_comment(): main_content = main.read() assert ( - "# Write your code here" not in main_content + "# Write your code here" not in main_content ), "Remove unnecessary comment"