Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

solved 2 #1639

wants to merge 2 commits into from

Conversation

Danylo-Ok
Copy link

No description provided.

# Write your code here
pass
def __init__(self, km: float) -> None:
self.km: float = km

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need annotation

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a 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":

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":

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":

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":

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:

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:

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:

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:

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:

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:

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].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants