Skip to content

Conversation

@Nevi-cpu
Copy link

@Nevi-cpu Nevi-cpu commented Nov 4, 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

Excellent work on the Distance class! The implementation correctly handles all the required arithmetic and comparison operations, which is the core of the task.

I am requesting a couple of changes to align your code with the project's checklist requirements.

  1. Type Annotations: The type hint for the other parameter in your magic methods is Any. Please make it more specific, such as Distance | int | float, as required by the type annotation guidelines.
  2. Unnecessary else blocks: In methods like __truediv__ and the comparison methods, you can remove the else block when the if block contains a return. The code inside the else can simply be unindented.

These changes are important for code clarity and adherence to the project's standards. Once they are made, your solution will be perfect!


✨ 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

app/main.py Outdated
def __repr__(self) -> str:
return f"Distance(km={self.km})"

def __add__(self, other: Any) -> Distance:

Choose a reason for hiding this comment

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

This violates the type annotation guidelines in the checklist. The other parameter should have a more specific type than Any, such as Distance | int | float. Please update the type hints for all magic methods to reflect the actual types they support.

app/main.py Outdated
if isinstance(other, (int, float)):
new_km = self.km * other
return self.__class__(new_km)
else:

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'). When an if block contains a return statement, the else block is redundant. You can remove the else and unindent return NotImplemented. This applies to __truediv__ and all comparison methods as well.

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 job on incorporating the feedback from the last review! Your code is looking much cleaner, especially with the removal of the unnecessary else blocks. However, a small but important change is needed before this can be approved. The type annotations for the other parameter in __mul__ and __truediv__ are not quite right. According to the project requirements, these methods should only accept numeric types. Please update the type hint in both methods to be int | float. This will align the code with the checklist requirement that "__truediv__ and __mul__ should not accept a Distance instance as an argument." Once that's fixed, your solution will be perfect. Keep up the great work!


✨ 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

app/main.py Outdated
return NotImplemented
return self

def __mul__(self, other: Distance | int | float) -> Distance:

Choose a reason for hiding this comment

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

The type annotation for the other parameter isn't quite right here. According to the requirements, this method should only accept numeric types, not another Distance instance.

This violates checklist item #1 under 'Support correct types': "__truediv__ and __mul__ should not accept Distance instance as argument." Please adjust the type hint to int | float.

app/main.py Outdated
return self.__class__(new_km)
return NotImplemented

def __truediv__(self, other: Distance | int | float) -> Distance:

Choose a reason for hiding this comment

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

Similar to __mul__, the type annotation for the other parameter here should only include numeric types.

This violates checklist item #1 under 'Support correct types': "__truediv__ and __mul__ should not accept Distance instance as argument." The type hint should be int | float.

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

Excellent work on this submission! You've done a great job addressing the previous feedback on type annotations, and your code now correctly meets all the functional requirements. I am approving this solution to help you keep moving forward, but there's a small stylistic improvement I'd like you to consider for future reference.

In your __add__ and __iadd__ methods, you can make the code a bit cleaner and more consistent with your other magic methods. By returning the result directly inside the if and elif blocks, you can remove the final else block. This change would better align with the 'Avoid unnecessary else statements' guideline. This is just a minor point of style, and overall, your logic is solid. Keep up the fantastic work!


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

Footnotes

  1. Rate AI review example

def __repr__(self) -> str:
return f"Distance(km={self.km})"

def __add__(self, other: Distance | int | float) -> Distance:

Choose a reason for hiding this comment

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

This method can be simplified to align with the style of the other magic methods in this class (like __mul__ or __lt__). By returning directly from within the if and elif blocks, you can remove the else block and the final return statement. This change would better follow the 'Avoid unnecessary else statements' guideline from the checklist.

return NotImplemented
return self.__class__(new_km)

def __iadd__(self, other: Distance | int | float) -> Distance:

Choose a reason for hiding this comment

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

Similar to the __add__ method, this implementation can be refactored for consistency and simplicity. Returning self directly inside the if and elif blocks would allow you to remove the else block and make the code more aligned with the 'Make Code Easier' checklist item.

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