Skip to content

Commit

Permalink
fixed linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dxrrkwm committed Oct 3, 2024
1 parent afac1d8 commit f9f7862
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 2 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Callable, Any


def cache(func: Callable) -> Callable:
storage = {}

Expand All @@ -12,4 +13,5 @@ def wrapper(*args, **kwargs) -> Any:
result = func(*args, **kwargs)
storage[args] = result
return result

return wrapper
20 changes: 9 additions & 11 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -31,7 +31,7 @@ def long_time_func(a, b, c):
)

assert (
out == output
out == output
), f"""
output must be:
{output},
Expand All @@ -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):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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():
Expand All @@ -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."


Expand All @@ -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"

0 comments on commit f9f7862

Please sign in to comment.