-
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 #822
base: master
Are you sure you want to change the base?
Solution #822
Conversation
app/main.py
Outdated
self.km += other.km | ||
return self | ||
elif isinstance(other, (int, float)): | ||
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.
Prefer using a single return statement for clarity
app/main.py
Outdated
def __le__(self, other: Distance | int | float) -> bool: | ||
if isinstance(other, Distance): | ||
return self.km <= other.km | ||
elif isinstance(other, (int, float)): | ||
return self.km <= other | ||
|
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.
To simplify the code for the method, you can use the concise approach by making use of the not self > other
expression. The same you can make in __ge__
method
app/main.py
Outdated
def __lt__(self, other: Distance | int | float) -> bool: | ||
if isinstance(other, Distance): | ||
return self.km < other.km | ||
elif isinstance(other, (int, float)): | ||
return self.km < other | ||
|
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 __lt__(self, other: Distance | int | float) -> bool: | |
if isinstance(other, Distance): | |
return self.km < other.km | |
elif isinstance(other, (int, float)): | |
return self.km < other | |
def __lt__(self, other: Distance | int | float) -> bool: | |
if isinstance(other, Distance): | |
return self.km < other.km | |
elif isinstance(other, (int, float)): | |
return self.km < other | |
else: | |
raise TypeError("some message") | |
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 everywhere
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 👍
No description provided.