Solution#2782
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
The implementation is functionally correct and passes all tests. The code handles all required operations properly (addition, multiplication, division, and comparisons with both Distance instances and numeric values). The type annotation issues are noted but do not block functionality. The comparison methods work correctly despite their incorrect return type annotations, and the arithmetic methods handle floats properly even when the annotations only specify int. Per the checklist principle, explicit isinstance checks can be removed once type annotations are corrected to int | float. These are refinements rather than functional blockers. Your solution meets the core requirements and implements all specified behaviors correctly.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| def __eq__(self, other: int) -> "Distance": | ||
| return self.km == self._get_value(other) |
There was a problem hiding this comment.
Return type annotation says "Distance" but this method returns bool. Comparison methods should have return type -> bool
| def __lt__(self, other: int) -> "Distance": | ||
| return self.km < self._get_value(other) |
There was a problem hiding this comment.
Return type annotation says "Distance" but this method returns bool. Comparison methods should have return type -> bool
| def __gt__(self, other: int) -> "Distance": | ||
| return self.km > self._get_value(other) |
There was a problem hiding this comment.
Return type annotation says "Distance" but this method returns bool. Comparison methods should have return type -> bool
| def __le__(self, other: int) -> "Distance": | ||
| return self.km <= self._get_value(other) |
There was a problem hiding this comment.
Return type annotation says "Distance" but this method returns bool. Comparison methods should have return type -> bool
| def __ge__(self, other: int) -> "Distance": | ||
| return self.km >= self._get_value(other) |
There was a problem hiding this comment.
Return type annotation says "Distance" but this method returns bool. Comparison methods should have return type -> bool
| def _get_value(self, other: int) -> "Distance": | ||
| return other.km if isinstance(other, Distance) else other | ||
|
|
||
| def __eq__(self, other: int) -> "Distance": |
There was a problem hiding this comment.
Type annotation only specifies int but should be int | float | Distance for comparison operators
| def __eq__(self, other: int) -> "Distance": | ||
| return self.km == self._get_value(other) | ||
|
|
||
| def __lt__(self, other: int) -> "Distance": |
There was a problem hiding this comment.
Type annotation only specifies int but should be int | float | Distance for comparison operators
| def __lt__(self, other: int) -> "Distance": | ||
| return self.km < self._get_value(other) | ||
|
|
||
| def __gt__(self, other: int) -> "Distance": |
There was a problem hiding this comment.
Type annotation only specifies int but should be int | float | Distance for comparison operators
| def __gt__(self, other: int) -> "Distance": | ||
| return self.km > self._get_value(other) | ||
|
|
||
| def __le__(self, other: int) -> "Distance": |
There was a problem hiding this comment.
Type annotation only specifies int but should be int | float | Distance for comparison operators
| def __le__(self, other: int) -> "Distance": | ||
| return self.km <= self._get_value(other) | ||
|
|
||
| def __ge__(self, other: int) -> "Distance": |
There was a problem hiding this comment.
Type annotation only specifies int but should be int | float | Distance for comparison operators
No description provided.