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 #1394

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

Solution #1394

wants to merge 3 commits into from

Conversation

Gleb1395
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Thank you for your hard work on this pull request! 😊 There are a couple of critical issues that need to be addressed before we can approve it. The long_time_func_2 function is expected to return an int, but it currently returns a list. Please adjust the function to return an integer or update the return type annotation if a list is indeed the intended return type. Additionally, the wrapper function should return a value of the same type as the decorated function, but it currently returns None. Please modify the return type to match the decorated function's return type. Once these issues are resolved, your code will be in great shape! Keep up the great work! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

app/main.py Outdated Show resolved Hide resolved
app/main.py Outdated Show resolved Hide resolved
Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Great effort on implementing the caching decorator and the associated functions! 🎉 However, there are a couple of critical issues that need your attention to ensure the code functions as intended:

  1. Return Type of long_time_func_2: The function is expected to return an int, but it currently returns a list. Please adjust the function to return an integer or update the return type annotation if a list is indeed the intended return type.

  2. Return Type of wrapper Function: The wrapper function within the cache decorator should return a value of the same type as the decorated function. Currently, it returns None if the cache is not hit, which is incorrect. It should return the result of the function call instead.

These issues are important for the functionality of your code, so please make sure to address them. The decision to approve is made to help you move forward with your learning journey. Keep up the great work, and make sure to learn from these points to improve your code in the future! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

app/main.py Outdated


@cache
def long_time_func_2(n_tuple: tuple, power: int) -> list:

Choose a reason for hiding this comment

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

The long_time_func_2 function is expected to return an int, but it currently returns a list. Please adjust the function to return an integer or update the return type annotation if a list is indeed the intended return type.

app/main.py Outdated
cache_dict = {}

def wrapper(*args, **kwargs) -> Any:
flag = True

Choose a reason for hiding this comment

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

Remove this flag variable

app/main.py Outdated
def wrapper(*args, **kwargs) -> Any:
flag = True
while flag:
data_iterable = tuple(

Choose a reason for hiding this comment

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

include kwargs as well

app/main.py Outdated
print("Calculating new result")
cache_dict[data_iterable] = func(*args, **kwargs)
return cache_dict[data_iterable]
else:

Choose a reason for hiding this comment

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

else operator is redundant. remove it

Copy link
Author

Choose a reason for hiding this comment

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

If I delete else how can I get the cached element back?

app/main.py Outdated

@cache
def long_time_func(a: int, b: int, c: int) -> int: # NOQA VNE001
return (a ** b ** c) % (a * c)

Choose a reason for hiding this comment

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

Please remove those examples from PR

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.

4 participants