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

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

Solution #681

wants to merge 3 commits into from

Conversation

AntonRzz
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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


Thank you for your hard work on this Pull Request! 😊 However, there are a few critical issues that need to be addressed to ensure the code functions correctly and meets the task requirements:

  1. Descriptor Methods: The __get__ and __set__ methods in the IntegerRange class are not implemented correctly. The __get__ method should return the value stored in the instance, and the __set__ method should set the attribute on the instance using setattr(instance, self.name, value).

  2. Slide Class Flexibility: The Slide class currently restricts the limitation_class to Type[AdultSlideLimitationValidator]. It should be more flexible by accepting any child class of SlideLimitationValidator, using Type[SlideLimitationValidator].

  3. Initialization of Validators: The ChildrenSlideLimitationValidator and AdultSlideLimitationValidator should not directly set age, weight, and height in their __init__ methods. Instead, they should rely on the IntegerRange descriptors for validation and setting these attributes.

  4. Error Handling: The can_access method should handle all possible exceptions that might be raised by the limitation_class, not just ValueError and TypeError.

Please address these issues to ensure the code meets the core requirements and functions as expected. Keep up the great work, and feel free to reach out if you have any questions or need further clarification! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

app/main.py Outdated
raise TypeError
if not self.min_amount <= value <= self.max_amount:
raise ValueError
self.value = value

Choose a reason for hiding this comment

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

The __set__ method should set the attribute on the instance using setattr(instance, self.name, value) instead of self.value = value. This ensures that the value is correctly assigned to the instance's attribute.

app/main.py Outdated
def __init__(
self,
name: str,
limitation_class: Type[AdultSlideLimitationValidator]

Choose a reason for hiding this comment

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

The limitation_class parameter is currently typed as Type[AdultSlideLimitationValidator], which restricts it to only accept AdultSlideLimitationValidator or its subclasses. If you intend to use different validators, consider using a more general type, such as Type[SlideLimitationValidator].

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Great job on improving the code! 🎉 While the Pull Request is approved to help you move forward with your learning, there are a few critical issues that need attention:

  1. Descriptor Methods: The __get__ method in the IntegerRange class should return the value stored in the instance as a single value, not a tuple. Please modify the return type to reflect this.

  2. Initialization of Validators: Both ChildrenSlideLimitationValidator and AdultSlideLimitationValidator classes should not directly set age, weight, and height in their __init__ methods. Instead, they should rely on the IntegerRange descriptors for validation and setting these attributes.

  3. Error Handling in can_access Method: The can_access method should handle all possible exceptions that might be raised by the limitation_class, not just ValueError and TypeError. Consider using a more general exception handling approach.

These improvements are crucial for ensuring the code functions correctly and meets the task requirements. Keep up the good work, and make sure to address these issues in future iterations to enhance your coding skills. Happy coding! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

app/main.py Outdated
Comment on lines 13 to 14
def __get__(self, instance: object, owner: Type) -> tuple:
return getattr(instance, self.privat_name)

Choose a reason for hiding this comment

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

The __get__ method should return the value stored in the instance as a single value, not a tuple. Modify the return type to reflect this.

app/main.py Outdated
Comment on lines 55 to 58
def __init__(self, age: int, weight: int, height: int) -> None:
self.age = age
self.weight = weight
self.height = height

Choose a reason for hiding this comment

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

The ChildrenSlideLimitationValidator class should not directly set age, weight, and height in the __init__ method. Instead, it should rely on the IntegerRange descriptors for validation and setting these attributes.

app/main.py Outdated
Comment on lines 66 to 69
def __init__(self, age: int, weight: int, height: int) -> None:
self.age = age
self.weight = weight
self.height = height

Choose a reason for hiding this comment

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

The AdultSlideLimitationValidator class should not directly set age, weight, and height in the __init__ method. Instead, it should rely on the IntegerRange descriptors for validation and setting these attributes.

app/main.py Outdated
Comment on lines 89 to 90
except (ValueError, TypeError):
return False

Choose a reason for hiding this comment

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

The can_access method should handle all possible exceptions that might be raised by the limitation_class, not just ValueError and TypeError. Consider using a more general exception handling approach.

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