-
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 #1632
base: master
Are you sure you want to change the base?
Solution #1632
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. Just a small note: for compatibility with Python versions prior to 3.10, consider using isinstance(other, (int, float))
for type checking instead of int | float
. Keep up the good work! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
app/main.py
Outdated
self.km = km | ||
|
||
def __add__(self, other: Union["Distance", int, float]) -> "Distance": | ||
if isinstance(other, int | float): |
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 use of int | float
for type checking is incorrect for Python versions prior to 3.10. Use isinstance(other, (int, float))
instead.
app/main.py
Outdated
) | ||
|
||
def __iadd__(self, other: Union["Distance", int, float]) -> "Distance": | ||
if isinstance(other, int | float): |
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 use of int | float
for type checking is incorrect for Python versions prior to 3.10. Use isinstance(other, (int, float))
instead.
app/main.py
Outdated
return Distance(round(self.km / other, 2)) | ||
|
||
def __lt__(self, other: Union["Distance", int, float]) -> bool: | ||
if isinstance(other, int | float): |
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 use of int | float
for type checking is incorrect for Python versions prior to 3.10. Use isinstance(other, (int, float))
instead.
app/main.py
Outdated
return self.km < other.km | ||
|
||
def __gt__(self, other: Union["Distance", int, float]) -> bool: | ||
if isinstance(other, int | float): |
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 use of int | float
for type checking is incorrect for Python versions prior to 3.10. Use isinstance(other, (int, float))
instead.
app/main.py
Outdated
return self.km > other.km | ||
|
||
def __eq__(self, other: Union["Distance", int, float]) -> bool: | ||
if isinstance(other, int | float): |
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 use of int | float
for type checking is incorrect for Python versions prior to 3.10. Use isinstance(other, (int, float))
instead.
app/main.py
Outdated
return self.km == other.km | ||
|
||
def __le__(self, other: Union["Distance", int, float]) -> bool: | ||
if isinstance(other, int | float): |
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 use of int | float
for type checking is incorrect for Python versions prior to 3.10. Use isinstance(other, (int, float))
instead.
app/main.py
Outdated
return self.km <= other.km | ||
|
||
def __ge__(self, other: Union["Distance", int, float]) -> bool: | ||
if isinstance(other, int | float): |
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 use of int | float
for type checking is incorrect for Python versions prior to 3.10. Use isinstance(other, (int, float))
instead.
No description provided.