-
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
Class Distance is made #1811
base: master
Are you sure you want to change the base?
Class Distance is made #1811
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! 🎉 Your code meets the task requirements and constraints effectively. While there are some minor issues with type annotations, they don't impact the functionality of your code. For future improvements, ensure that the return types for methods like __add__
, __iadd__
, __mul__
, __truediv__
, and comparison methods are specified correctly to enhance code readability and maintainability. Keep up the excellent work! 😊
✨ 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 __add__(self, other: Distance) -> Any: |
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 return type for the __add__
method should be Distance
instead of Any
, as it always returns a Distance
instance.
if isinstance(other, int) or isinstance(other, float): | ||
return Distance(self.km + other) | ||
|
||
def __iadd__(self, other: Distance) -> Any: |
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 return type for the __iadd__
method should be Distance
instead of Any
, as it always returns a Distance
instance.
self.km = self.km + other | ||
return self | ||
|
||
def __mul__(self, other: Any) -> Any: |
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 return type for the __mul__
method should be Distance
instead of Any
, as it always returns a Distance
instance.
if isinstance(other, int) or isinstance(other, float): | ||
return Distance(self.km * other) | ||
|
||
def __truediv__(self, other: Any) -> Any: |
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 return type for the __truediv__
method should be Distance
instead of Any
, as it always returns a Distance
instance.
def __repr__(self) -> str: | ||
return f"Distance(km={self.km})" | ||
|
||
def __lt__(self, other: Distance) -> Any: |
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 return type for comparison methods like __lt__
should be bool
instead of Any
, as they return a boolean value.
if isinstance(other, int) or isinstance(other, float): | ||
return self.km < other | ||
|
||
def __gt__(self, other: Distance) -> Any: |
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 return type for comparison methods like __gt__
should be bool
instead of Any
, as they return a boolean value.
if isinstance(other, int) or isinstance(other, float): | ||
return self.km > other | ||
|
||
def __eq__(self, other: Distance) -> Any: |
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 return type for comparison methods like __eq__
should be bool
instead of Any
, as they return a boolean value.
if isinstance(other, int) or isinstance(other, float): | ||
return self.km == other | ||
|
||
def __le__(self, other: Distance) -> Any: |
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 return type for comparison methods like __le__
should be bool
instead of Any
, as they return a boolean value.
if isinstance(other, int) or isinstance(other, float): | ||
return self.km <= other | ||
|
||
def __ge__(self, other: Distance) -> Any: |
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 return type for comparison methods like __ge__
should be bool
instead of Any
, as they return a boolean value.
No description provided.