Skip to content

Solution#2776

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

Solution#2776
Vova-Zabila wants to merge 1 commit into
mate-academy:masterfrom
Vova-Zabila:develop

Conversation

@Vova-Zabila

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

Your Distance class implementation is functionally correct and meets all core requirements. The code passes all functional tests and the arithmetic and comparison operations work as expected. The __mul__ and __truediv__ methods accept float values correctly at runtime, but your type annotations specify num: int and other: int respectively. Per the requirements, these should be num: int | float and other: int | float. While this doesn't break functionality, fixing these annotations will make your code fully compliant with the type specification. Several comparison and arithmetic methods use else blocks after if statements. These could be refactored to use early returns for cleaner code, though this is a minor style improvement rather than a functional issue. The implementation is solid and works correctly—consider the above suggestions as polish rather than blockers.


✨ 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 +27 to +28

def __mul__(self, num: 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 specifies int but should be int | float according to requirements (Distance * int/float).

Comment thread app/main.py
Comment on lines +30 to +31

def __truediv__(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 specifies int but should be int | float according to requirements (Distance / int/float).

Comment thread app/main.py
Comment on lines +35 to +37
def __lt__(self, other : Distance | int | float) -> bool:
if isinstance(other, Distance):
return self.km < other.km

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This violates checklist item #1: avoid unnecessary else statements. Use early return pattern instead.

Comment thread app/main.py
Comment on lines +41 to +44
def __gt__(self, other: Distance | int | float) -> bool:
if isinstance(other, Distance):
return self.km > other.km
else:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This violates checklist item #1: avoid unnecessary else statements. Use early return pattern instead.

Comment thread app/main.py
Comment on lines +47 to +50
def __eq__(self, other: Distance | int | float) -> bool:
if isinstance(other, Distance):
return self.km == other.km
else:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This violates checklist item #1: avoid unnecessary else statements. Use early return pattern instead.

Comment thread app/main.py
Comment on lines +53 to +56
def __le__(self, other: Distance | int | float) -> bool:
if isinstance(other, Distance):
return self.km <= other.km
else:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This violates checklist item #1: avoid unnecessary else statements. Use early return pattern instead.

Comment thread app/main.py
Comment on lines +59 to +62
def __ge__(self, other: Distance | int | float) -> bool:
if isinstance(other, Distance):
return self.km >= other.km
else:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This violates checklist item #1: avoid unnecessary else statements. Use early return pattern instead.

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