Skip to content

Commit

Permalink
fixed solution
Browse files Browse the repository at this point in the history
  • Loading branch information
dxrrkwm committed Oct 16, 2024
1 parent c43eb74 commit 2d789b4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def __get__(self, instance: object, owner: object) -> int:
return getattr(instance, self.protected_name)

def __set__(self, instance: object, value: int) -> None:
if not isinstance(value, int):
raise TypeError(f"{self.protected_name} must be an integer")
if not self.min_amount <= value <= self.max_amount:
raise ValueError(f"{value} must be in range:" # noqa
f" {self.min_amount} - {self.max_amount}")
Expand Down Expand Up @@ -64,6 +66,6 @@ def __init__(self, name: str, limitation_class: type) -> None:
def can_access(self, visitor: Visitor) -> bool:
try:
self.limitation_class(visitor.age, visitor.weight, visitor.height)
except ValueError:
except (ValueError, TypeError):
return False
return True

0 comments on commit 2d789b4

Please sign in to comment.