-
Notifications
You must be signed in to change notification settings - Fork 620
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 #285
base: master
Are you sure you want to change the base?
Solution #285
Conversation
app/main.py
Outdated
self.limitation_class = limitation_class | ||
|
||
def can_access(self, client: Visitor) -> bool: | ||
return len(self.limitation_class( |
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.
why do you use dict?it is strange logic. it would be better to use try-except here
app/main.py
Outdated
pass | ||
def __init__(self, | ||
name: str, | ||
limitation_class: SlideLimitationValidator |
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.
limitation_class: SlideLimitationValidator | |
limitation_class: Type[SlideLimitationValidator] |
app/main.py
Outdated
return getattr(instance, self.protected_name) | ||
|
||
def __set__(self, instance: callable, value: int) -> None: | ||
if value in range(self.min_amount, self.max_amount + 1): |
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.
and raise here ValueError if value not in range
Added raise ValueError to IntegerRange.set, added try-except to Slide.can_access method |
self.limitation_class(client.age, client.height, client.weight) | ||
return True | ||
except 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.
return False | |
return False | |
return True |
app/main.py
Outdated
def can_access(self, client: Visitor) -> bool: | ||
try: | ||
self.limitation_class(client.age, client.height, client.weight) | ||
return True |
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.
and delete from here
Pycharm highlights limitation_class: SlideLimitationValidator and warns that 'SlideLimitationValidator' object is not callable, but the code passes all tests