-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
base: master
Are you sure you want to change the base?
Solution #1394
Conversation
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.
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.
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.
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:
-
Return Type of
long_time_func_2
: The function is expected to return anint
, but it currently returns alist
. Please adjust the function to return an integer or update the return type annotation if a list is indeed the intended return type. -
Return Type of
wrapper
Function: Thewrapper
function within thecache
decorator should return a value of the same type as the decorated function. Currently, it returnsNone
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: |
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.
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 |
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.
Remove this flag variable
app/main.py
Outdated
def wrapper(*args, **kwargs) -> Any: | ||
flag = True | ||
while flag: | ||
data_iterable = tuple( |
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 kwargs as well
app/main.py
Outdated
print("Calculating new result") | ||
cache_dict[data_iterable] = func(*args, **kwargs) | ||
return cache_dict[data_iterable] | ||
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. remove it
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.
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) |
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 remove those examples from PR
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.