-
Notifications
You must be signed in to change notification settings - Fork 696
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
created shop trip func #589
Conversation
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.
Several changes were requested
with open("app/config.json", "r") as file_info: | ||
all_info = json.load(file_info) |
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.
Do not overload a context manage, perform only load operation within it.
app/main.py
Outdated
cost_for_trip = round( | ||
2 * customer.car.calculate_trip_cost( | ||
customer.car.calculate_distance( | ||
customer.location, | ||
shop.location | ||
), | ||
fuel_price | ||
) | ||
+ shop.calculate_cost_for_products(customer.product_cart) | ||
, 2) |
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.
In case there are no arguments on the same line with an opening parenthesis, your closing parenthesis should not have any arguments on the same line as well. Please, resolve this issue
app/main.py
Outdated
f"doesn't have enough money to make a purchase in any shop") | ||
else: | ||
chippest_shop = list(costs_for_trips.keys())[ | ||
list(costs_for_trips.values()).index( |
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.
Leave no arguments for closing parenthesis as it is don for an opening one
app/shops.py
Outdated
total_sum = 0 | ||
for product in product_cart: | ||
total_sum += product_cart[product] * self.products[product] | ||
|
||
return total_sum |
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.
You could use sum
and generator expression here
app/config.json
Outdated
@@ -73,4 +73,4 @@ | |||
} | |||
} | |||
] | |||
} | |||
} |
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.
Add a blank line at the end of the file here
app/main.py
Outdated
print(f"{customer.name} " | ||
f"doesn't have enough money to make a purchase in any shop") | ||
else: | ||
chippest_shop = list(costs_for_trips.keys())[ |
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.
Please find another, simple way to find chippest_shop
Maybe you can do it during iteration over list_of_shops
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.
LGTM, well done! One comment is left for conisderation
f"now has {customer.money} dollars\n") | ||
|
||
|
||
shop_trip() |
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.
Place the function calls in the file inside of the if __name__ == "__main__"
block in the future
No description provided.