From: Ysabel <5388340+togogh@users.noreply.github.com> Date: Thu, 30 Jan 2025 12:19:10 +0000 (+0800) Subject: 📝 Update Request Body's `tutorial002` to deal with `tax=0` case (#13230) X-Git-Tag: 0.115.8~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9667ce87a908eecc2be2a215adcb55c7e1b38040;p=thirdparty%2Ffastapi%2Ffastapi.git 📝 Update Request Body's `tutorial002` to deal with `tax=0` case (#13230) Co-authored-by: svlandeg --- diff --git a/docs_src/body/tutorial002.py b/docs_src/body/tutorial002.py index 7f51839082..5cd86216b3 100644 --- a/docs_src/body/tutorial002.py +++ b/docs_src/body/tutorial002.py @@ -17,7 +17,7 @@ app = FastAPI() @app.post("/items/") async def create_item(item: Item): item_dict = item.dict() - if item.tax: + if item.tax is not None: price_with_tax = item.price + item.tax item_dict.update({"price_with_tax": price_with_tax}) return item_dict diff --git a/docs_src/body/tutorial002_py310.py b/docs_src/body/tutorial002_py310.py index 8928b72b8d..454c45c886 100644 --- a/docs_src/body/tutorial002_py310.py +++ b/docs_src/body/tutorial002_py310.py @@ -15,7 +15,7 @@ app = FastAPI() @app.post("/items/") async def create_item(item: Item): item_dict = item.dict() - if item.tax: + if item.tax is not None: price_with_tax = item.price + item.tax item_dict.update({"price_with_tax": price_with_tax}) return item_dict