Skip to content

Conversation

@AlexMishKo
Copy link

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! The core logic for arithmetic and comparisons is mostly correct. However, there is a critical issue in your error handling that needs to be fixed. In the __truediv__ method, you are returning ZeroDivisionError instead of raising it. This is a functional bug because it won't stop execution as an exception should. Please change this to raise ZeroDivisionError("Cannot divide by zero") and update the method's return type hint accordingly.

Additionally, please address a few checklist violations:

  • The type hints for the other parameter in __mul__ and __truediv__ should not accept a Distance instance.
  • To improve your type annotations, add from __future__ import annotations to the top of the file and remove the quotes from "Distance".

Once these changes are made, your code will be ready for approval!


✨ 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

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

app/main.py Outdated
def __truediv__(self, other: Union[int, float, "Distance"])\
-> Union["Distance", type(ZeroDivisionError)]:
if not isinstance(other, (int, float)):
return NotImplemented

Choose a reason for hiding this comment

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

Please remove the NotImplemented return in all methods, as the methods return None by default. Here is an example of how you can simplify the code:
def truediv(self, other: int | float) -> Distance | None:
if isinstance(other, (int, float)) and other != 0:
return Distance(round(self.km / other, 2)) . Simplify logic in other methods please.

Copy link
Author

Choose a reason for hiding this comment

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

Done it, but i cant see any changes here on git hub. need ur help pls^^

@AlexMishKo AlexMishKo requested a review from DonDmytron October 31, 2025 05:28
Comment on lines +37 to +38
if isinstance(other, (int, float)):
return Distance(self.km * other)

Choose a reason for hiding this comment

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

You don't need this check here, your function anyway takes only int and float types, according to your type annotations

app/main.py Outdated
Comment on lines 62 to 68
def __le__(self, other: Union[int, float, Distance]) -> bool:
other_km = self._get_km_value(other)
return self.km <= other_km

def __ge__(self, other: Union[int, float, Distance]) -> bool:
other_km = self._get_km_value(other)
return self.km >= other_km

Choose a reason for hiding this comment

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

try to rewrite these two methods in one line each. Use previously created magic methods
Hint: <= is the same as not >

Copy link

@DonDmytron DonDmytron left a comment

Choose a reason for hiding this comment

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

fix it, please
Screenshot 2025-10-31 at 15 34 27

@AlexMishKo AlexMishKo requested a review from DonDmytron November 1, 2025 16:09
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