-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #1329
base: master
Are you sure you want to change the base?
Solution #1329
Conversation
app/main.py
Outdated
|
||
@wraps(func) | ||
def wrapper(*args) -> Any: | ||
if args in cache_store: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**kwargs and function name should be included as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added **kwargs, what did you mean by "function name"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed the code, please check
app/main.py
Outdated
if args in cache_store: | ||
print("Getting from cache") | ||
return cache_store[args] | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else
operator is redundant here
tests/test_main.py
Outdated
@@ -171,6 +171,42 @@ def delay_addition(a, b): | |||
assert time3 - time2 < 1, "Cache decorator should return cached value." | |||
|
|||
|
|||
def test_use_named_arguments(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not modify tests folder. All changes should be done in main.py
app/main.py
Outdated
|
||
@wraps(func) | ||
def wrapper(*args, **kwargs) -> Any: | ||
cache_key = f"{args}, {kwargs}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include funtion name into cache_key as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GJ!
No description provided.