Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solution #1711

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

solution #1711

wants to merge 4 commits into from

Conversation

giantsmall
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.

Thank you for your hard work on this implementation! 😊 There are a few critical issues that need to be addressed to meet the core requirements of the task:

  1. Return Type for __mul__ and __truediv__: These methods should return a new Distance instance rather than modifying the existing one. This is crucial as it aligns with the task requirement that these operations should yield a new Distance object.

  2. Comparison Methods: The comparison methods (__lt__, __gt__, __eq__, __le__, __ge__) need to handle comparisons with both Distance instances and numeric types (int, float). This is essential for the functionality of the class as it ensures flexibility and correctness in comparisons.

Once these issues are resolved, your code will be much closer to meeting the task requirements. Keep up the great work, and don't hesitate to reach out if you need further assistance! 🚀

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

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

app/main.py Outdated
Comment on lines 29 to 31
def __mul__(self, factor: float) -> float:
self.km *= factor
return self

Choose a reason for hiding this comment

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

The __mul__ method should return a new Distance instance instead of modifying self and returning it. This aligns with the task requirement that the result of multiplication should be a new Distance object.

app/main.py Outdated
Comment on lines 33 to 35
def __truediv__(self, divisor: float) -> float:
self.km = round(self.km / divisor, 2)
return self

Choose a reason for hiding this comment

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

The __truediv__ method should return a new Distance instance instead of modifying self and returning it. Ensure the result is a new Distance object as specified in the task description.

app/main.py Outdated
Comment on lines 37 to 38
def __lt__(self, distance: float) -> bool:
return self.km < distance

Choose a reason for hiding this comment

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

The __lt__ method should be able to compare Distance objects as well as numeric types. Consider checking if distance is an instance of Distance and adjust the comparison accordingly.

app/main.py Outdated
Comment on lines 40 to 41
def __gt__(self, distance: float) -> bool:
return self.km > distance

Choose a reason for hiding this comment

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

The __gt__ method should handle comparisons with both Distance instances and numeric types. Ensure to check the type of distance and perform the comparison appropriately.

app/main.py Outdated
Comment on lines 43 to 44
def __eq__(self, distance: float) -> bool:
return self.km == distance

Choose a reason for hiding this comment

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

The __eq__ method should be able to compare Distance objects as well as numeric types. Adjust the logic to handle both cases.

app/main.py Outdated
Comment on lines 46 to 47
def __le__(self, distance: float) -> bool:
return self < distance or self == distance

Choose a reason for hiding this comment

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

The __le__ method should handle comparisons with both Distance instances and numeric types. Ensure the logic accommodates both scenarios.

app/main.py Outdated
Comment on lines 49 to 50
def __ge__(self, distance: float) -> bool:
return self > distance or self == distance

Choose a reason for hiding this comment

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

The __ge__ method should be able to compare Distance objects as well as numeric types. Adjust the logic to handle both cases.

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 effort on implementing the Distance class with several magic methods! 🎉 While your implementation is mostly correct, there are a couple of critical issues that need attention:

  1. Return Type for __mul__ and __truediv__: Currently, these methods return a float, but they should return a new Distance instance. This is crucial as the task specifies that these operations should yield a new Distance object. Ensure the return type annotation is updated to Distance.

  2. Comparison Methods: You've done a great job with the comparison methods (__lt__, __gt__, __eq__, __le__, __ge__). They correctly handle comparisons with both Distance instances and numeric types, aligning well with the task requirements.

The decision to approve is made to help you move forward with your learning journey. However, please review the comments and address these issues to improve your code. It's important to fix these critical issues to ensure the functionality aligns with the task requirements. Keep up the good work, and continue learning from these experiences! 🚀

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

Comment on lines +29 to +30
def __mul__(self, factor: float) -> float:
return Distance(self.km * factor)

Choose a reason for hiding this comment

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

The __mul__ method should return a new Distance instance, not a float. The return type annotation should be Distance instead of float.

Comment on lines +32 to +33
def __truediv__(self, divisor: float) -> float:
return Distance(round(self.km / divisor, 2))

Choose a reason for hiding this comment

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

The __truediv__ method should return a new Distance instance, not a float. The return type annotation should be Distance instead of float.

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