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 #918

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

Solution #918

wants to merge 2 commits into from

Conversation

serji13
Copy link

@serji13 serji13 commented Jan 4, 2024

No description provided.

app/main.py Outdated
Comment on lines 14 to 22
def __add__(self, other: Distance | int | float) -> Distance:
if isinstance(other, Distance):
return Distance(
km=self.km + other.km
)
if isinstance(other, (int, float)):
return Distance(
km=self.km + other
)

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: Distance | int | float) -> Distance:
if isinstance(other, Distance):
return Distance(
km=self.km + other.km
)
if isinstance(other, (int, float)):
return Distance(
km=self.km + other
)
def __add__(self, other: Distance | int | float) -> Distance:
if isinstance(other, Distance):
return Distance(
km=self.km + other.km
)
return Distance(
km=self.km + other
)

Choose a reason for hiding this comment

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

Fix this everywhere. As you defined that function gets only Distance / int / float -> you don't need to use second if.

@serji13 serji13 requested a review from YukihiroSM January 4, 2024 14:37
Copy link

@EdAlekseiev EdAlekseiev 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.

3 participants