-
Notifications
You must be signed in to change notification settings - Fork 674
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
base: master
Are you sure you want to change the base?
Solution #649
Conversation
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.
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
def __get__(self, instance: str, owner: str) -> None: | ||
return getattr(instance, self.name) |
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.
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.
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 |
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.
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.
def can_access(self, visitor: Visitor) -> bool: | ||
try: | ||
self.limitation_class(visitor.age, visitor.weight, visitor.height) |
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.
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.
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.
Great effort on implementing the IntegerRange
descriptor and the Slide
class! 🎉 However, there are a few key areas that need attention:
-
IntegerRange
Descriptor: You've done well with the__get__
and__set__
methods, which correctly manage attribute values using the instance's dictionary. -
Slide
Class: Thecan_access
method should utilize thelimitation_class
for validation. Instead of directly accessing the visitor's attributes, instantiate thelimitation_class
and use it to validate the attributes. This ensures that the validation logic is applied correctly. -
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
def can_access(self, visitor: Visitor) -> bool: | ||
try: | ||
visitor.age, visitor.weight, visitor.height | ||
return True | ||
except (TypeError, ValueError): | ||
return False |
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.
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.
No description provided.