-
Notifications
You must be signed in to change notification settings - Fork 663
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 #670
base: master
Are you sure you want to change the base?
solution #670
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.
Great job on implementing the task requirements! 🎉 While there are a few areas for improvement, such as using the IntegerRange
descriptors correctly in the can_access
method and providing more descriptive error messages, these are minor issues that don't significantly impact the functionality. Keep up the good work and consider these suggestions for future enhancements! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
|
||
def __set__(self, instance: object, value: int) -> None: | ||
if not isinstance(value, int): | ||
raise TypeError |
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.
Consider providing a more descriptive error message when raising the TypeError
to indicate that the value must be an integer.
if self.min_amount <= value <= self.max_amount: | ||
setattr(instance, self.protected_name, value) | ||
else: | ||
setattr(instance, self.protected_name, None) |
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.
Instead of setting the attribute to None
when the value is out of range, it would be more appropriate to raise a ValueError
with a descriptive message. This will make it clear that the value is invalid and why.
self.limitation_class = limitation_class | ||
|
||
def can_access(self, man: Visitor) -> bool: | ||
access = self.limitation_class(man.age, man.weight, man.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 currently creates an instance of the limitation class with the visitor's attributes. However, the IntegerRange
descriptors are not being used correctly. You should check if the visitor's attributes are within the allowed range using the descriptors, rather than relying on the instantiation of the limitation class.
No description provided.