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

solution #809

Closed
wants to merge 3 commits into from
Closed

solution #809

wants to merge 3 commits into from

Conversation

Andrey1104
Copy link

No description provided.

Copy link

@Dimosphen1 Dimosphen1 left a 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:

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:

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.

@Andrey1104 Andrey1104 requested a review from Dimosphen1 October 23, 2023 16:40
app/main.py Outdated
Comment on lines 22 to 25
self.km += other.km
return self
self.km += other
return self

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:

Choose a reason for hiding this comment

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

Suggested change
def __add__(self, other: (int, float, Distance)) -> Distance:
def __add__(self, other: int | float | Distance) -> Distance:

Choose a reason for hiding this comment

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

fix in all places

Copy link

@Polyakiv-Andrey Polyakiv-Andrey left a comment

Choose a reason for hiding this comment

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

Good job!

@Andrey1104 Andrey1104 closed this by deleting the head repository Mar 23, 2024
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.

4 participants