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

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

Solution #1643

wants to merge 2 commits into from

Conversation

AntonRzz
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 implementing the Distance class! Your code is mostly on point and meets the task requirements. However, there are a few critical issues that need to be addressed before we can approve the pull request:

  1. Type Annotations for Comparison Methods: The comparison methods (__lt__, __gt__, __eq__, __le__, __ge__) should return a bool, not a Distance object. This is important for the expected behavior of comparison operations.

  2. Division by Zero Handling: In the __truediv__ method, please add a check to handle division by zero. This will prevent runtime errors and ensure your code is robust.

  3. Handling Non-Numeric Types in __mul__: The __mul__ method should return NotImplemented when other is not an int or float. This will make your code more flexible and error-resistant.

Once these issues are resolved, your implementation will be in great shape! Keep up the great work, and I'm looking forward to seeing the improvements. 😊

✨ 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 Show resolved Hide resolved
app/main.py Show resolved Hide resolved
app/main.py Outdated
return Distance(round(self.km / other, 2))
return NotImplemented

def __lt__(self, other: int) -> "Distance":

Choose a reason for hiding this comment

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

The return type for the __lt__ method should be bool, not Distance. This applies to all comparison methods.

app/main.py Outdated
return self.km < other.km
return self.km < other

def __gt__(self, other: int) -> "Distance":

Choose a reason for hiding this comment

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

The return type for the __gt__ method should be bool, not Distance. This applies to all comparison methods.

app/main.py Outdated
return self.km > other.km
return self.km > other

def __eq__(self, other: int) -> "Distance":

Choose a reason for hiding this comment

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

The return type for the __eq__ method should be bool, not Distance. This applies to all comparison methods.

app/main.py Outdated
return self.km == other.km
return self.km == other

def __le__(self, other: int) -> "Distance":

Choose a reason for hiding this comment

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

The return type for the __le__ method should be bool, not Distance. This applies to all comparison methods.

app/main.py Outdated
return self.km <= other.km
return self.km <= other

def __ge__(self, other: int) -> "Distance":

Choose a reason for hiding this comment

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

The return type for the __ge__ method should be bool, not Distance. This applies to all comparison methods.

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: 7]

If the issue is within your control, please address it.
The next review attempt will automatically launch in 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.

Great job on improving the Distance class implementation! 🎉 You've made significant progress by correcting the type annotations for the comparison methods and ensuring proper handling of division by zero. However, there are still a few areas that need attention:

  • Type Annotations: Ensure that the other parameter in the comparison methods (__lt__, __gt__, __eq__, __le__, __ge__) is annotated as Union[Distance, int, float] to match the types being checked.
  • __truediv__ Method: Include float in the type annotation for the other parameter, as the method checks for both int and float types.

These adjustments will enhance the robustness and clarity of your code. Remember, addressing these issues will not only improve your current implementation but also help you avoid similar problems in the future. 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! ✨

return Distance(self.km * other)
return NotImplemented

def __truediv__(self, other: int) -> "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 in the __truediv__ method should include float as well, since the method checks for both int and float types.

return Distance(round(self.km / other, 2))
return NotImplemented

def __lt__(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 type annotation for the other parameter in the __lt__ method should be Union[Distance, int, float] to match the types being checked in the method.

return self.km < other.km
return self.km < other

def __gt__(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 type annotation for the other parameter in the __gt__ method should be Union[Distance, int, float] to match the types being checked in the method.

return self.km > other.km
return self.km > other

def __eq__(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 type annotation for the other parameter in the __eq__ method should be Union[Distance, int, float] to match the types being checked in the method.

return self.km == other.km
return self.km == other

def __le__(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 type annotation for the other parameter in the __le__ method should be Union[Distance, int, float] to match the types being checked in the method.

return self.km <= other.km
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 type annotation for the other parameter in the __ge__ method should be Union[Distance, int, float] to match the types being checked in the method.

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

def __add__(self, other: Union["Distance", int, float]) -> "Distance":
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def __add__(self, other: Union["Distance", int, float]) -> "Distance":
def __add__(self, other: Union[Distance, int, float]) -> "Distance":

please fix everywhere

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