Skip to content

Added solution#2798

Open
666phx wants to merge 1 commit into
mate-academy:masterfrom
666phx:master
Open

Added solution#2798
666phx wants to merge 1 commit into
mate-academy:masterfrom
666phx:master

Conversation

@666phx

@666phx 666phx commented Jun 8, 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 Distance class implementation is working correctly and meets all functional requirements. All magic methods (__init__, __str__, __repr__, arithmetic operations, and comparison methods) are properly implemented, and the type annotations correctly exclude Distance from __mul__ and __truediv__ as specified. There's one minor style note: the __iadd__ method contains an unnecessary else statement. Since the if branch always returns, the else is redundant. You can simply place the else body directly after the if block. However, this is a cosmetic issue that doesn't affect functionality—all tests pass and the code works as intended. Great work on the implementation!


✨ 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 +21 to +26
def __iadd__(self, other: Union[Distance, int, float]) -> Distance:
if isinstance(other, Distance):
self.km += other.km
else:
self.km += other
return self

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 uses an unnecessary else statement. Per checklist item #1, avoid else by restructuring. Example: use a ternary for the value and add it once, or return early after the if block.

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