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 #1710

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

Solution #1710

wants to merge 4 commits into from

Conversation

Revko
Copy link

@Revko Revko commented Jan 31, 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.

Thank you for your hard work on the Distance class! 🚀 While your implementation is mostly correct, there are a few critical issues that need to be addressed to fully meet the task requirements:

  1. Comparison Methods: The __ge__, __le__, __eq__, __gt__, and __lt__ methods should be able to handle comparisons with both Distance objects and numeric types. Currently, they only handle numeric types. Please update these methods to include checks for Distance objects.

  2. __iadd__ Return Type: The return type for the __iadd__ method should be Distance, not (int, float). This method should return the modified instance of Distance.

Once these issues are resolved, your code will be in great shape! Keep up the excellent 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
elif isinstance(other, (int, float)):
return Distance(self.km + other)

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

Choose a reason for hiding this comment

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

The return type of the __iadd__ method should be Distance, not (int, float). According to the task description, this method should return the modified instance of Distance.

def __truediv__(self, other: (int, float)) -> "Distance":
return Distance(round(self.km / other, 2))

def __lt__(self, other: (int, float)) -> bool:

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 with both Distance objects and numeric types. Currently, it only compares with numeric types. You should add a check to handle Distance objects as well.

app/main.py Outdated
def __lt__(self, other: (int, float)) -> bool:
return self.km < other

def __gt__(self, other: (int, float)) -> bool:

Choose a reason for hiding this comment

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

The __gt__ method should be able to compare with both Distance objects and numeric types. Currently, it only compares with numeric types. You should add a check to handle Distance objects as well.

app/main.py Outdated
def __gt__(self, other: (int, float)) -> bool:
return self.km > other

def __eq__(self, other: (int, float)) -> bool:

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 with both Distance objects and numeric types. Currently, it only compares with numeric types. You should add a check to handle Distance objects as well.

app/main.py Outdated
def __eq__(self, other: (int, float)) -> bool:
return self.km == other

def __le__(self, other: (int, float)) -> bool:

Choose a reason for hiding this comment

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

The __le__ method should be able to compare with both Distance objects and numeric types. Currently, it only compares with numeric types. You should add a check to handle Distance objects as well.

app/main.py Outdated
def __le__(self, other: (int, float)) -> bool:
return self.km <= other

def __ge__(self, other: int) -> bool:

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 with both Distance objects and numeric types. Currently, it only compares with numeric types. You should add a check to handle Distance objects 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.

Great job on improving the Distance class implementation! 🎉 The comparison methods now correctly handle both Distance objects and numeric types, which is a significant enhancement. However, there's a minor inconsistency with the parameter type hint in the __ge__ method. It should be aligned with the other comparison methods to allow both Distance objects and numeric types.

Your __iadd__ method is spot on, returning the modified instance as required. Overall, your code meets the task requirements and constraints, and all necessary files are present.

Remember, addressing the type hint issue will further polish your code. Keep up the great work and continue learning from these experiences. Your efforts are paying off, and you're on the right track! 🚀

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

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

def __ge__(self, other: int) -> bool:

Choose a reason for hiding this comment

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

The parameter type hint for the __ge__ method is inconsistent with the other comparison methods. It should allow both Distance objects and numeric types, similar to the other methods.

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.

3 participants