Skip to content

Solution#2782

Open
EnZ09 wants to merge 1 commit into
mate-academy:masterfrom
EnZ09:develop
Open

Solution#2782
EnZ09 wants to merge 1 commit into
mate-academy:masterfrom
EnZ09:develop

Conversation

@EnZ09

@EnZ09 EnZ09 commented May 28, 2026

Copy link
Copy Markdown

No description provided.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

  1. Rate AI review example

Comment thread app/main.py
Comment on lines +42 to +43
def __eq__(self, other: int) -> "Distance":
return self.km == self._get_value(other)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Return type annotation says "Distance" but this method returns bool. Comparison methods should have return type -> bool

Comment thread app/main.py
Comment on lines +45 to +46
def __lt__(self, other: int) -> "Distance":
return self.km < self._get_value(other)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Return type annotation says "Distance" but this method returns bool. Comparison methods should have return type -> bool

Comment thread app/main.py
Comment on lines +48 to +49
def __gt__(self, other: int) -> "Distance":
return self.km > self._get_value(other)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Return type annotation says "Distance" but this method returns bool. Comparison methods should have return type -> bool

Comment thread app/main.py
Comment on lines +51 to +52
def __le__(self, other: int) -> "Distance":
return self.km <= self._get_value(other)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Return type annotation says "Distance" but this method returns bool. Comparison methods should have return type -> bool

Comment thread app/main.py
Comment on lines +54 to +55
def __ge__(self, other: int) -> "Distance":
return self.km >= self._get_value(other)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Return type annotation says "Distance" but this method returns bool. Comparison methods should have return type -> bool

Comment thread app/main.py
def _get_value(self, other: int) -> "Distance":
return other.km if isinstance(other, Distance) else other

def __eq__(self, other: int) -> "Distance":

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Type annotation only specifies int but should be int | float | Distance for comparison operators

Comment thread app/main.py
def __eq__(self, other: int) -> "Distance":
return self.km == self._get_value(other)

def __lt__(self, other: int) -> "Distance":

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Type annotation only specifies int but should be int | float | Distance for comparison operators

Comment thread app/main.py
def __lt__(self, other: int) -> "Distance":
return self.km < self._get_value(other)

def __gt__(self, other: int) -> "Distance":

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Type annotation only specifies int but should be int | float | Distance for comparison operators

Comment thread app/main.py
def __gt__(self, other: int) -> "Distance":
return self.km > self._get_value(other)

def __le__(self, other: int) -> "Distance":

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Type annotation only specifies int but should be int | float | Distance for comparison operators

Comment thread app/main.py
def __le__(self, other: int) -> "Distance":
return self.km <= self._get_value(other)

def __ge__(self, other: int) -> "Distance":

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Type annotation only specifies int but should be int | float | Distance for comparison operators

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