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

Done #815

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

Done #815

wants to merge 5 commits into from

Conversation

Moonralex
Copy link

No description provided.

app/main.py Outdated
Comment on lines 3 to 7
# "I'm not sure if this is the best solution"
# " for creating accurate type annotations, "
# "but the others are not working for me."

T = TypeVar("T", bound="Distance")

Choose a reason for hiding this comment

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

this is not a good idea. You can use Distance for type annotation

Copy link
Author

Choose a reason for hiding this comment

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

2023-11-07 22 04 33
When I attempt to implement type annotations like this, I encounter an error when running pytest, as indicated in the screenshot.

Choose a reason for hiding this comment

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

Place from __future__ import annotations on the first line, it should resolve the issue. In case not, make sure that you have Python 3.11 installed and bound to the IDE to utilize the latest functionality. You should use the plain Distance in the type annotation. If all steps described above are not successful, visit one of the Q&A sessions to resolve the issue.

app/main.py Outdated
Comment on lines 28 to 33
if isinstance(other, Distance):
self.km += other.km
return self
if isinstance(other, (int, float)):
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 it with one return

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
Comment on lines 3 to 7
# "I'm not sure if this is the best solution"
# " for creating accurate type annotations, "
# "but the others are not working for me."

T = TypeVar("T", bound="Distance")

Choose a reason for hiding this comment

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

Place from __future__ import annotations on the first line, it should resolve the issue. In case not, make sure that you have Python 3.11 installed and bound to the IDE to utilize the latest functionality. You should use the plain Distance in the type annotation. If all steps described above are not successful, visit one of the Q&A sessions to resolve the issue.

@Moonralex Moonralex requested a review from Dimosphen1 November 9, 2023 14:33
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!

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