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

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

Solution #1469

wants to merge 1 commit into from

Conversation

Sichkaridze
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! 🎉 Your code meets all the task requirements and constraints effectively. The caching mechanism works well, storing and retrieving results as expected. Just a small note: ensure that both positional and keyword arguments are checked for immutability to prevent any potential issues. Keep up the excellent work! 😊

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

Comment on lines +8 to +9
if any(isinstance(arg, (list, dict, set)) for arg in args):
raise ValueError("All arguments must be immutable")

Choose a reason for hiding this comment

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

The check for immutability only covers the positional arguments (args). You should also check the keyword arguments (kwargs) to ensure they are immutable. Consider iterating over kwargs.values() as well.

def wrapper(*args, **kwargs) -> Callable:
if any(isinstance(arg, (list, dict, set)) for arg in args):
raise ValueError("All arguments must be immutable")
key = (func, args, frozenset(kwargs.items()))

Choose a reason for hiding this comment

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

Using frozenset to convert kwargs.items() into an immutable type is correct, but ensure that all values in kwargs are hashable. If any value is a mutable type, it will raise an error.

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