-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 #809
solution #809
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.
Several changes were requested.
app/main.py
Outdated
def __repr__(self) -> str: | ||
return f"Distance(km={self.km})" | ||
|
||
def __add__(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.
Be more specific in your type annotations and indicate that other
could be either an int
, float
, or Distance
instance and that the return type would be always a Distance
class instance. Make such changes to other methods where applicable.
app/main.py
Outdated
return self.km <= other.km | ||
return self.km <= other | ||
|
||
def __ge__(self, other: Any) -> bool: |
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.
You could implement some methods based on the implemented functionality of others. E.g. self
is greater or equal to other
when self
is not less than other
.
app/main.py
Outdated
self.km += other.km | ||
return self | ||
self.km += other | ||
return self |
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.
write this code with one return
app/main.py
Outdated
def __repr__(self) -> str: | ||
return f"Distance(km={self.km})" | ||
|
||
def __add__(self, other: (int, float, Distance)) -> Distance: |
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.
def __add__(self, other: (int, float, Distance)) -> Distance: | |
def __add__(self, other: int | float | Distance) -> Distance: |
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.
fix in all places
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.
Good job!
No description provided.