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

easy #1461

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

easy #1461

wants to merge 1 commit into from

Conversation

zaebalsya1
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.

Great job on implementing the caching decorator! 🎉 The code meets the task requirements and functions correctly. Just a couple of things to keep in mind: ensure your Python environment supports the type annotations you're using, and remember to use immutable types for cache keys to avoid potential issues. Keep up the good work!

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


@wraps(func)
def wrapper(*args: Any) -> Any:
if args in func_cache:

Choose a reason for hiding this comment

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

Using mutable types like lists or dictionaries as keys in a dictionary will raise a TypeError because they are not hashable. Ensure that the arguments used as keys in func_cache are immutable. Consider converting mutable arguments to immutable types, such as tuples, before using them as keys.



@cache
def long_time_func_2(numbers: Tuple[int, ...], power: int) -> list[int]:

Choose a reason for hiding this comment

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

The function long_time_func_2 returns a list, but the return type annotation specifies list[int], which is correct for Python 3.9 and above. Ensure that your Python environment supports this syntax, or use List[int] with an appropriate import from typing for compatibility with earlier versions.

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