Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Solution #1329

wants to merge 4 commits into from

Conversation

matweyes
Copy link

@matweyes matweyes commented Oct 2, 2024

No description provided.

app/main.py Outdated

@wraps(func)
def wrapper(*args) -> Any:
if args in cache_store:
Copy link

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

Copy link
Author

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"?

Copy link
Author

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:
Copy link

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

@matweyes matweyes requested a review from pavlopro October 6, 2024 08:59
@@ -171,6 +171,42 @@ def delay_addition(a, b):
assert time3 - time2 < 1, "Cache decorator should return cached value."


def test_use_named_arguments():
Copy link

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}"
Copy link

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

@matweyes matweyes requested a review from pavlopro October 6, 2024 17:34
Copy link

@pavlopro pavlopro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GJ!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants