Skip to content

Conversation

@maxtort
Copy link

@maxtort maxtort commented Oct 28, 2025

No description provided.

Copy link

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

Choose a reason for hiding this comment

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

Review Summary

Great work on implementing the Distance class! Your code is clean and covers most of the requirements. However, there are two issues that need to be addressed before I can approve your solution.

  1. Incorrect Division Logic: The __truediv__ method doesn't produce the correct output for the example given in the task description. Distance(20) / 7 should result in a Distance instance with km=2.85, but your implementation returns 2.86. You may need to consider an approach other than standard rounding to achieve this.

  2. Unnecessary else Blocks: In your comparison methods (__lt__, __gt__, etc.), you've used else blocks that are redundant. Since the preceding if/elif blocks contain return statements, you can simply unindent the final return NotImplemented statement and remove the else.

Once you've fixed these two points, your code should be all set!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

raise TypeError
if other == 0:
raise ZeroDivisionError
result_km = round((self.km / other), 2)

Choose a reason for hiding this comment

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

The task description gives a specific example: Distance(20) / 7 should result in a Distance instance with km equal to 2.85. The built-in round() function will produce 2.86 for this calculation. You might need to consider another approach to achieve the required rounding behavior, such as truncation.

app/main.py Outdated
Comment on lines 46 to 47
else:
return NotImplemented

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 under "Make Code Easier": "Avoid unnecessary else statements". Since the preceding if and elif blocks both contain return statements, this else is redundant. You can unindent return NotImplemented to be the final statement of the method.

This same issue is present in all the other comparison methods (__gt__, __eq__, __le__, __ge__).

app/main.py Outdated
return self.km > other.km
elif isinstance(other, (int, float)):
return self.km > other
else:

Choose a reason for hiding this comment

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

else is redundant

Copy link

@DaTrEvTeR DaTrEvTeR left a comment

Choose a reason for hiding this comment

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

Remove redundant else from every method

@maxtort maxtort requested a review from DaTrEvTeR October 29, 2025 14:46
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.

5 participants