-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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' #1702
base: master
Are you sure you want to change the base?
'Solution' #1702
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.
Your implementation of the Distance
class is well-done and meets the task requirements! 🎉 The class handles arithmetic operations and comparisons effectively. While there is a minor suggestion to improve the type hints for better clarity and to remove some unnecessary else
statements, these do not impact the functionality. Keep up the great work, and consider these suggestions for future improvements! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
def __repr__(self) -> str: | ||
return f"Distance(km={self.km})" | ||
|
||
def __add__(self, other: int) -> "Distance": |
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 type hint for the other
parameter should include both Distance
and int
, as the method is designed to handle both types. Consider changing it to Union[Distance, int]
.
km=self.km + other | ||
) | ||
|
||
def __iadd__(self, other: int) -> "Distance": |
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 type hint for the other
parameter should include both Distance
and int
, as the method is designed to handle both types. Consider changing it to Union[Distance, int]
.
self.km = self.km + other | ||
return self | ||
|
||
def __mul__(self, other: int) -> "Distance": |
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 type hint for the other
parameter should include both Distance
and int
, as the method is designed to handle both types. Consider changing it to Union[Distance, int]
.
def __mul__(self, other: int) -> "Distance": | ||
return Distance(km=self.km * other) | ||
|
||
def __truediv__(self, other: int) -> "Distance": |
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 type hint for the other
parameter should include both Distance
and int
, as the method is designed to handle both types. Consider changing it to Union[Distance, int]
.
def __truediv__(self, other: int) -> "Distance": | ||
return Distance(km=round(self.km / other, 2)) | ||
|
||
def __lt__(self, other: int) -> bool: |
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 type hint for the other
parameter should include both Distance
and int
, as the method is designed to handle both types. Consider changing it to Union[Distance, int]
.
else: | ||
return self.km < other | ||
|
||
def __gt__(self, other: int) -> bool: |
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 type hint for the other
parameter should include both Distance
and int
, as the method is designed to handle both types. Consider changing it to Union[Distance, int]
.
else: | ||
return self.km > other | ||
|
||
def __eq__(self, other: int) -> bool: |
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 type hint for the other
parameter should include both Distance
and int
, as the method is designed to handle both types. Consider changing it to Union[Distance, int]
.
else: | ||
return self.km == other | ||
|
||
def __le__(self, other: int) -> bool: |
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 type hint for the other
parameter should include both Distance
and int
, as the method is designed to handle both types. Consider changing it to Union[Distance, int]
.
else: | ||
return self.km <= other | ||
|
||
def __ge__(self, other: int) -> bool: |
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 type hint for the other
parameter should include both Distance
and int
, as the method is designed to handle both types. Consider changing it to Union[Distance, int]
.
No description provided.