-
Notifications
You must be signed in to change notification settings - Fork 672
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
base: master
Are you sure you want to change the base?
Solution #681
Conversation
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.
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:
-
Descriptor Methods: The
__get__
and__set__
methods in theIntegerRange
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 usingsetattr(instance, self.name, value)
. -
Slide Class Flexibility: The
Slide
class currently restricts thelimitation_class
toType[AdultSlideLimitationValidator]
. It should be more flexible by accepting any child class ofSlideLimitationValidator
, usingType[SlideLimitationValidator]
. -
Initialization of Validators: The
ChildrenSlideLimitationValidator
andAdultSlideLimitationValidator
should not directly setage
,weight
, andheight
in their__init__
methods. Instead, they should rely on theIntegerRange
descriptors for validation and setting these attributes. -
Error Handling: The
can_access
method should handle all possible exceptions that might be raised by thelimitation_class
, not justValueError
andTypeError
.
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 |
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.
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] |
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.
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]
.
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.
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:
-
Descriptor Methods: The
__get__
method in theIntegerRange
class should return the value stored in the instance as a single value, not a tuple. Please modify the return type to reflect this. -
Initialization of Validators: Both
ChildrenSlideLimitationValidator
andAdultSlideLimitationValidator
classes should not directly setage
,weight
, andheight
in their__init__
methods. Instead, they should rely on theIntegerRange
descriptors for validation and setting these attributes. -
Error Handling in
can_access
Method: Thecan_access
method should handle all possible exceptions that might be raised by thelimitation_class
, not justValueError
andTypeError
. 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
def __get__(self, instance: object, owner: Type) -> tuple: | ||
return getattr(instance, self.privat_name) |
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.
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
def __init__(self, age: int, weight: int, height: int) -> None: | ||
self.age = age | ||
self.weight = weight | ||
self.height = height |
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.
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
def __init__(self, age: int, weight: int, height: int) -> None: | ||
self.age = age | ||
self.weight = weight | ||
self.height = height |
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.
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
except (ValueError, TypeError): | ||
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.
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.
No description provided.