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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Solution #1658

wants to merge 1 commit into from

Conversation

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

Great job on implementing the Distance class! 🎉 The core functionality is solid, and you've met the task requirements. Just a couple of minor improvements: ensure the type hints include int and float for better clarity, and handle division by zero with an exception. Keep up the great work! 🚀

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

# /
def __truediv__(self, other: int | float) -> Distance:
if other == 0:
return Distance(other)

Choose a reason for hiding this comment

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

The __truediv__ method should raise an exception when dividing by zero instead of returning a Distance object with zero. Consider using raise ZeroDivisionError('division by zero').

return Distance(km=result)

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

Choose a reason for hiding this comment

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

The type hint for the other parameter should include int and float as well as Distance. Update it to other: Distance | int | float.

return self.km < other.km

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

Choose a reason for hiding this comment

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

The type hint for the other parameter should include int and float as well as Distance. Update it to other: Distance | int | float.

return self.km > other.km

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

Choose a reason for hiding this comment

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

The type hint for the other parameter should include int and float as well as Distance. Update it to other: Distance | int | float.

return self.km == other.km

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

Choose a reason for hiding this comment

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

The type hint for the other parameter should include int and float as well as Distance. Update it to other: Distance | int | float.

return self.km <= other.km

def __ge__(self, other: Distance) -> bool:
if isinstance(other, (int, float)):

Choose a reason for hiding this comment

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

The type hint for the other parameter should include int and float as well as Distance. Update it to other: Distance | int | 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