-
Notifications
You must be signed in to change notification settings - Fork 673
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 #350
base: master
Are you sure you want to change the base?
Solution #350
Conversation
if self.min_amount <= value <= self.max_amount: | ||
setattr(obj, self.protected_name, value) |
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.
raise ValueError when get incorrect value and add descriptive error message
app/main.py
Outdated
def validate(self) -> bool: | ||
return (4 <= self.age <= 14 | ||
and 80 <= self.height <= 120 | ||
and 20 <= self.weight <= 50) |
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.
you should make validation by using IntegerRange
app/main.py
Outdated
def validate(self) -> bool: | ||
return (14 <= self.age <= 60 | ||
and 120 <= self.height <= 220 | ||
and 50 <= self.weight <= 120) |
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.
same here
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.
LGTM, well done! One comment is left for consideration. Besides that, consider placing arguments on a new line in case they have type annotations, it could improve the readability later on.
if self.limitation_class( | ||
age=visitor.age, | ||
height=visitor.height, | ||
weight=visitor.weight | ||
): |
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.
There is no need to create an if condition, you could just make an initialization of a limitation_class
.
No description provided.