-
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
Task done #769
base: master
Are you sure you want to change the base?
Task done #769
Conversation
app/main.py
Outdated
# Write your code here | ||
pass | ||
def wrapper(*args) -> str: | ||
func_name = f"{func}({args})" |
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.
This is redundant
app/main.py
Outdated
@@ -1,6 +1,19 @@ | |||
from typing import Callable | |||
|
|||
|
|||
cache_history = dict() |
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.
This variable must be inside decorator, to create separate state for each function
app/main.py
Outdated
def wrapper(*args) -> str: | ||
# func_name = f"{func}({args})" | ||
|
||
if f"{func}({args})" in cache_history: |
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 f"{func}({args})" in cache_history: | |
if args in cache_history: |
Why do you need func?
Remove it from all places
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 added the function name to the cache because I moved the cache to outside the decorator. In this case arguments could be repeated for different functions.
I corrected it as you recommended.
What else can I add to make the code better?
app/main.py
Outdated
cache_history = dict() | ||
|
||
def wrapper(*args) -> str: | ||
# func_name = f"{func}({args})" |
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 comment
app/main.py
Outdated
pass | ||
cache_history = dict() | ||
|
||
def wrapper(*args) -> str: |
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.
def wrapper(*args) -> str: | |
def wrapper(*args) -> Any: |
No description provided.