Skip to content

Commit 4fed048

Browse files
authored
bugfix: updated tutorial002_py310.py so the code works properly when tax=0
Before this commit, price_with_tax was not included in the response body when tax=0, because the "if item.tax" condition gets set to false. Changing the condition to "if item.tax is not None" solves this issue
1 parent ea0cdd1 commit 4fed048

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

docs_src/body/tutorial002_py310.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Item(BaseModel):
1515
@app.post("/items/")
1616
async def create_item(item: Item):
1717
item_dict = item.dict()
18-
if item.tax:
18+
if item.tax is not None:
1919
price_with_tax = item.price + item.tax
2020
item_dict.update({"price_with_tax": price_with_tax})
2121
return item_dict

0 commit comments

Comments
 (0)