-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 #1803
base: master
Are you sure you want to change the base?
Solution #1803
Conversation
There was a problem hiding this 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 with all the required functionalities! 🎉 While there are some minor issues with type annotations, they don't affect the functionality of your code. For future improvements, consider updating the return type annotations to reflect the actual return types, such as using -> bool
for comparison methods and -> Distance
for arithmetic methods. Keep up the good work and happy coding! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
def __init__(self, km: int) -> None: | ||
self.km = km | ||
|
||
def __str__(self) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The __str__
method should return a string, but the return type annotation is None
. It should be -> str
.
def __str__(self) -> None: | ||
return f"Distance: {self.km} kilometers." | ||
|
||
def __repr__(self) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The __repr__
method should return a string, but the return type annotation is None
. It should be -> str
.
def __repr__(self) -> None: | ||
return f"Distance(km={self.km})" | ||
|
||
def __add__(self, other: "Distance | int | float") -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The __add__
method should return a Distance
object, but the return type annotation is None
. It should be -> Distance
.
else: | ||
raise TypeError("Unsupported operand type for +") | ||
|
||
def __iadd__(self, other: "Distance | int | float") -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The __iadd__
method should return a Distance
object, but the return type annotation is None
. It should be -> Distance
.
raise TypeError("Unsupported operand type for +") | ||
return self | ||
|
||
def __mul__(self, other: "Distance | int | float") -> None: |
There was a problem hiding this comment.
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 Distance
object, but the return type annotation is None
. It should be -> Distance
.
else: | ||
raise TypeError("Unsupported operand type for /") | ||
|
||
def __lt__(self, other: "Distance | int | float") -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The __lt__
method should return a boolean, but the return type annotation is None
. It should be -> bool
.
else: | ||
raise TypeError("Unsupported operand type for <") | ||
|
||
def __gt__(self, other: "Distance | int | float") -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The __gt__
method should return a boolean, but the return type annotation is None
. It should be -> bool
.
else: | ||
raise TypeError("Unsupported operand type for >") | ||
|
||
def __eq__(self, other: "Distance | int | float") -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The __eq__
method should return a boolean, but the return type annotation is None
. It should be -> bool
.
else: | ||
return False | ||
|
||
def __le__(self, other: "Distance | int | float") -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The __le__
method should return a boolean, but the return type annotation is None
. It should be -> bool
.
def __le__(self, other: "Distance | int | float") -> None: | ||
return self.__lt__(other) or self.__eq__(other) | ||
|
||
def __ge__(self, other: "Distance | int | float") -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The __ge__
method should return a boolean, but the return type annotation is None
. It should be -> bool
.
No description provided.