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

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

Solution #649

wants to merge 4 commits into from

Conversation

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

Thank you for your hard work on this project! 😊 While your implementation covers most of the task requirements, there are a few critical issues that need to be addressed to ensure the code functions correctly. Specifically, the IntegerRange descriptor's __get__ and __set__ methods need to interact with the instance's dictionary to manage attribute values properly. Additionally, the can_access method should rely on the descriptors for validation rather than directly instantiating SlideLimitationValidator. Once these issues are resolved, your code will be in great shape! Keep up the great work, and don't hesitate to reach out if you need further guidance. 🚀

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

app/main.py Outdated
Comment on lines 12 to 13
def __get__(self, instance: str, owner: str) -> None:
return getattr(instance, self.name)

Choose a reason for hiding this comment

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

The __get__ method should return the value from the instance's dictionary using instance.__dict__[self.name] instead of getattr(instance, self.name). This is because descriptors are meant to manage instance attributes directly.

Comment on lines +15 to +19
def __set__(self, instance: str, value: str) -> None:
if not isinstance(value, int):
raise TypeError
if not self.min_amount <= value <= self.max_amount:
raise ValueError

Choose a reason for hiding this comment

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

The __set__ method should set the value in the instance's dictionary using instance.__dict__[self.name] = value after validation. This ensures that the descriptor correctly manages the attribute value.

Comment on lines +67 to +69
def can_access(self, visitor: Visitor) -> bool:
try:
self.limitation_class(visitor.age, visitor.weight, visitor.height)

Choose a reason for hiding this comment

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

The can_access method should not instantiate SlideLimitationValidator directly. Instead, the Visitor attributes should be set, and the descriptors will automatically validate them. Consider removing the instantiation and relying on the descriptors for validation.

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 effort on implementing the IntegerRange descriptor and the Slide class! 🎉 However, there are a few key areas that need attention:

  1. IntegerRange Descriptor: You've done well with the __get__ and __set__ methods, which correctly manage attribute values using the instance's dictionary.

  2. Slide Class: The can_access method should utilize the limitation_class for validation. Instead of directly accessing the visitor's attributes, instantiate the limitation_class and use it to validate the attributes. This ensures that the validation logic is applied correctly.

  3. Error Handling: Ensure that any errors raised during validation are handled appropriately within the can_access method.

Remember, addressing these issues will enhance the functionality and robustness of your code. Keep up the good work and continue learning from these experiences! 🚀

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

app/main.py Outdated
Comment on lines 69 to 74
def can_access(self, visitor: Visitor) -> bool:
try:
visitor.age, visitor.weight, visitor.height
return True
except (TypeError, ValueError):
return False

Choose a reason for hiding this comment

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

The can_access method should rely on the IntegerRange descriptors for validation rather than directly accessing the visitor's attributes. You should attempt to set the visitor's attributes using the descriptors, which will automatically trigger the validation logic. This approach ensures that the validation constraints are respected.

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