-
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
solved 2 #1639
base: master
Are you sure you want to change the base?
solved 2 #1639
Conversation
# Write your code here | ||
pass | ||
def __init__(self, km: float) -> None: | ||
self.km: float = km |
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.
No need annotation
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 all the task requirements and constraints. While there are some minor issues with type annotations, they don't affect the functionality of your code. Consider updating the type annotations to Union[float, Distance]
for better clarity and future-proofing. Keep up the good work! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
def __repr__(self) -> str: | ||
return f"Distance(km={self.km})" | ||
|
||
def __add__(self, other: float) -> "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.
The __add__
method's parameter other
is annotated as float
, but it can also be a Distance
instance. Consider changing the annotation to Union[float, Distance]
.
return Distance(self.km + other.km) | ||
return Distance(self.km + other) | ||
|
||
def __iadd__(self, other: float) -> "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.
The __iadd__
method's parameter other
is annotated as float
, but it can also be a Distance
instance. Consider changing the annotation to Union[float, Distance]
.
self.km += other | ||
return self | ||
|
||
def __mul__(self, other: float) -> "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.
The __mul__
method's parameter other
is annotated as float
, but it can also be a Distance
instance. Consider changing the annotation to Union[float, Distance]
.
def __mul__(self, other: float) -> "Distance": | ||
return Distance(self.km * other) | ||
|
||
def __truediv__(self, other: float) -> "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.
The __truediv__
method's parameter other
is annotated as float
, but it can also be a Distance
instance. Consider changing the annotation to Union[float, Distance]
.
raise ZeroDivisionError("division by zero") | ||
return Distance(round(self.km / other, 2)) | ||
|
||
def __lt__(self, other: float) -> 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.
The __lt__
method's parameter other
is annotated as float
, but it can also be a Distance
instance. Consider changing the annotation to Union[float, Distance]
.
def __lt__(self, other: float) -> bool: | ||
return self.km < (other.km if isinstance(other, Distance) else other) | ||
|
||
def __le__(self, other: float) -> 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.
The __le__
method's parameter other
is annotated as float
, but it can also be a Distance
instance. Consider changing the annotation to Union[float, Distance]
.
def __le__(self, other: float) -> bool: | ||
return self.km <= (other.km if isinstance(other, Distance) else other) | ||
|
||
def __eq__(self, other: float) -> 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.
The __eq__
method's parameter other
is annotated as float
, but it can also be a Distance
instance. Consider changing the annotation to Union[float, Distance]
.
def __eq__(self, other: float) -> bool: | ||
return self.km == (other.km if isinstance(other, Distance) else other) | ||
|
||
def __ne__(self, other: float) -> 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.
The __ne__
method's parameter other
is annotated as float
, but it can also be a Distance
instance. Consider changing the annotation to Union[float, Distance]
.
def __ne__(self, other: float) -> bool: | ||
return self.km != (other.km if isinstance(other, Distance) else other) | ||
|
||
def __gt__(self, other: float) -> 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.
The __gt__
method's parameter other
is annotated as float
, but it can also be a Distance
instance. Consider changing the annotation to Union[float, Distance]
.
def __gt__(self, other: float) -> bool: | ||
return self.km > (other.km if isinstance(other, Distance) else other) | ||
|
||
def __ge__(self, other: float) -> 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.
The __ge__
method's parameter other
is annotated as float
, but it can also be a Distance
instance. Consider changing the annotation to Union[float, Distance]
.
No description provided.