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

Task done #769

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

Conversation

aleksandr-paslawski
Copy link

No description provided.

app/main.py Outdated
# Write your code here
pass
def wrapper(*args) -> str:
func_name = f"{func}({args})"

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()

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:

Choose a reason for hiding this comment

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

Suggested change
if f"{func}({args})" in cache_history:
if args in cache_history:

Why do you need func?
Remove it from all places

Copy link
Author

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})"

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:

Choose a reason for hiding this comment

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

Suggested change
def wrapper(*args) -> str:
def wrapper(*args) -> Any:

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.

3 participants