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

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

Solution #285

wants to merge 3 commits into from

Conversation

Filllick
Copy link

Pycharm highlights limitation_class: SlideLimitationValidator and warns that 'SlideLimitationValidator' object is not callable, but the code passes all tests

app/main.py Outdated
self.limitation_class = limitation_class

def can_access(self, client: Visitor) -> bool:
return len(self.limitation_class(

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

Choose a reason for hiding this comment

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

Suggested change
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):

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

@Filllick
Copy link
Author

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

Choose a reason for hiding this comment

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

Suggested change
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

Choose a reason for hiding this comment

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

and delete from here

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