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

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

Conversation

KostiantinPastukh
Copy link

No description provided.

app/main.py Outdated
Comment on lines 10 to 13
def __get__(self, instance: Any, owner: Any) -> Any:
return getattr(instance, self.protected_name)

def __set__(self, instance: Any, value: int) -> Any:
Copy link

Choose a reason for hiding this comment

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

The annotation is incorrect.

app/main.py Outdated
def __init__(
self,
name: str,
limitation_class: SlideLimitationValidator
Copy link

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
Comment on lines 60 to 67
def can_access(self, visitor: Visitor) -> bool:
try:
self.limitation_class.age = visitor.age
self.limitation_class.height = visitor.height
self.limitation_class.weight = visitor.weight
except (TypeError, ValueError):
return False
return True
Copy link

Choose a reason for hiding this comment

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

Suggested change
def can_access(self, visitor: Visitor) -> bool:
try:
self.limitation_class.age = visitor.age
self.limitation_class.height = visitor.height
self.limitation_class.weight = visitor.weight
except (TypeError, ValueError):
return False
return True
def can_access(self, visitor: Visitor) -> bool:
try:
self.limitation_class(visitor.age, visitor.height, visitor.weight)
except (TypeError, ValueError):
return False
return True

app/main.py Outdated
Comment on lines 10 to 14
def __get__(self, instance: Any, owner: type) -> Any:
return getattr(instance, self.protected_name)

def __set__(self, instance: Any, value: int) -> Any:
if not isinstance(value, int):
Copy link

Choose a reason for hiding this comment

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

Suggested change
def __get__(self, instance: Any, owner: type) -> Any:
return getattr(instance, self.protected_name)
def __set__(self, instance: Any, value: int) -> Any:
if not isinstance(value, int):
def __get__(self, instance: Any, owner: type) -> Any:
return getattr(instance, self.protected_name)
def __set__(self, instance: Any, value: int) -> Any:
if not isinstance(value, int):

app/main.py Outdated
self.min_amount = min_amount
self.max_amount = max_amount

def __get__(self, instance: Any, owner: type) -> Any:
Copy link

Choose a reason for hiding this comment

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

Suggested change
def __get__(self, instance: Any, owner: type) -> Any:
def __get__(self, instance: object, owner: type) -> Any:

app/main.py Outdated
def __get__(self, instance: Any, owner: type) -> Any:
return getattr(instance, self.protected_name)

def __set__(self, instance: Any, value: int) -> Any:
Copy link

Choose a reason for hiding this comment

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

Suggested change
def __set__(self, instance: Any, value: int) -> Any:
def __set__(self, instance: object, value: int) -> Any:

Copy link

@vsmutok vsmutok left a comment

Choose a reason for hiding this comment

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

Great!

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