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

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

Solution #1670

wants to merge 1 commit into from

Conversation

kkatkot
Copy link

@kkatkot kkatkot commented Jan 8, 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.

Your implementation of the Distance class is well-structured and meets the task requirements. 🎉 The only minor issue is with the type annotations, where quotes are used unnecessarily. Consider using from __future__ import annotations to handle forward references without quotes. Keep up the great work and happy coding! 😊

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

@@ -1,3 +1,52 @@
class Distance:
# Write your code here
pass
def __init__(self, km: "int | float") -> None:

Choose a reason for hiding this comment

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

The type hint km: "int | float" should not be enclosed in quotes. It should be km: int | float.

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.

The type hint other: '"Distance" | int | float' should not be enclosed in quotes. It should be other: Distance | int | float.

return Distance(self.km + other)
return Distance(self.km + other.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.

The type hint other: '"Distance" | int | float' should not be enclosed in quotes. It should be other: Distance | int | float.

def __mul__(self, other: int) -> "Distance":
return Distance(self.km * other)

def __truediv__(self, other: "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 hint other: "int | float" should not be enclosed in quotes. It should be other: int | float.

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

def __lt__(self, other: '"Distance" | int | float') -> bool:

Choose a reason for hiding this comment

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

The type hint other: '"Distance" | int | float' should not be enclosed in quotes. It should be other: Distance | int | float.

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

def __gt__(self, other: '"Distance" | int | float') -> bool:

Choose a reason for hiding this comment

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

The type hint other: '"Distance" | int | float' should not be enclosed in quotes. It should be other: Distance | int | float.

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

def __eq__(self, other: '"Distance" | int | float') -> bool:

Choose a reason for hiding this comment

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

The type hint other: '"Distance" | int | float' should not be enclosed in quotes. It should be other: Distance | int | float.

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

def __le__(self, other: '"Distance" | int | float') -> bool:

Choose a reason for hiding this comment

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

The type hint other: '"Distance" | int | float' should not be enclosed in quotes. It should be other: Distance | int | float.

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

def __ge__(self, other: '"Distance" | int | float') -> bool:

Choose a reason for hiding this comment

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

The type hint other: '"Distance" | int | float' should not be enclosed in quotes. It should be 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