From 7e2518350ad2ab529ba1166c304ee299b616f42f Mon Sep 17 00:00:00 2001 From: Pankaj Giri Date: Sat, 13 Jun 2020 01:11:44 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Remove=20*,=20from=20functions?= =?UTF-8?q?=20where=20it's=20not=20needed=20#1234=20(#1239)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix for - [FEATURE] Remove *, where it's not needed #1234 * 🔥 Remove unnecessary arg *, * 🎨 Update docs format highlight lines Co-authored-by: Sebastián Ramírez --- docs/en/docs/tutorial/schema-extra-example.md | 2 +- docs_src/body_fields/tutorial001.py | 2 +- docs_src/body_multiple_params/tutorial002.py | 2 +- docs_src/body_multiple_params/tutorial003.py | 2 +- docs_src/body_multiple_params/tutorial005.py | 2 +- docs_src/body_nested_models/tutorial001.py | 2 +- docs_src/body_nested_models/tutorial002.py | 2 +- docs_src/body_nested_models/tutorial003.py | 2 +- docs_src/body_nested_models/tutorial004.py | 2 +- docs_src/body_nested_models/tutorial005.py | 2 +- docs_src/body_nested_models/tutorial006.py | 2 +- docs_src/body_nested_models/tutorial007.py | 2 +- docs_src/body_nested_models/tutorial008.py | 2 +- docs_src/cookie_params/tutorial001.py | 2 +- docs_src/extra_models/tutorial001.py | 2 +- docs_src/extra_models/tutorial002.py | 2 +- docs_src/header_params/tutorial001.py | 2 +- docs_src/header_params/tutorial002.py | 2 +- docs_src/path_operation_advanced_configuration/tutorial004.py | 2 +- docs_src/path_operation_configuration/tutorial001.py | 2 +- docs_src/path_operation_configuration/tutorial002.py | 2 +- docs_src/path_operation_configuration/tutorial003.py | 2 +- docs_src/path_operation_configuration/tutorial004.py | 2 +- docs_src/path_operation_configuration/tutorial005.py | 2 +- docs_src/request_forms/tutorial001.py | 2 +- docs_src/response_model/tutorial002.py | 2 +- docs_src/response_model/tutorial003.py | 2 +- docs_src/schema_extra_example/tutorial001.py | 2 +- docs_src/schema_extra_example/tutorial002.py | 2 +- docs_src/schema_extra_example/tutorial003.py | 3 +-- docs_src/security/tutorial004.py | 2 +- docs_src/security/tutorial005.py | 2 +- 32 files changed, 32 insertions(+), 33 deletions(-) diff --git a/docs/en/docs/tutorial/schema-extra-example.md b/docs/en/docs/tutorial/schema-extra-example.md index 70c3d1846..8a497ccd5 100644 --- a/docs/en/docs/tutorial/schema-extra-example.md +++ b/docs/en/docs/tutorial/schema-extra-example.md @@ -33,7 +33,7 @@ The same way you can pass extra info to `Field`, you can do the same with `Path` For example, you can pass an `example` for a body request to `Body`: -```Python hl_lines="20 21 22 23 24 25" +```Python hl_lines="19 20 21 22 23 24" {!../../../docs_src/schema_extra_example/tutorial003.py!} ``` diff --git a/docs_src/body_fields/tutorial001.py b/docs_src/body_fields/tutorial001.py index 7b2c9454d..dcd5b9764 100644 --- a/docs_src/body_fields/tutorial001.py +++ b/docs_src/body_fields/tutorial001.py @@ -12,6 +12,6 @@ class Item(BaseModel): @app.put("/items/{item_id}") -async def update_item(*, item_id: int, item: Item = Body(..., embed=True)): +async def update_item(item_id: int, item: Item = Body(..., embed=True)): results = {"item_id": item_id, "item": item} return results diff --git a/docs_src/body_multiple_params/tutorial002.py b/docs_src/body_multiple_params/tutorial002.py index 5c9e8344d..54f6d9138 100644 --- a/docs_src/body_multiple_params/tutorial002.py +++ b/docs_src/body_multiple_params/tutorial002.py @@ -17,6 +17,6 @@ class User(BaseModel): @app.put("/items/{item_id}") -async def update_item(*, item_id: int, item: Item, user: User): +async def update_item(item_id: int, item: Item, user: User): results = {"item_id": item_id, "item": item, "user": user} return results diff --git a/docs_src/body_multiple_params/tutorial003.py b/docs_src/body_multiple_params/tutorial003.py index 301f1a862..691fe848b 100644 --- a/docs_src/body_multiple_params/tutorial003.py +++ b/docs_src/body_multiple_params/tutorial003.py @@ -18,7 +18,7 @@ class User(BaseModel): @app.put("/items/{item_id}") async def update_item( - *, item_id: int, item: Item, user: User, importance: int = Body(...) + item_id: int, item: Item, user: User, importance: int = Body(...) ): results = {"item_id": item_id, "item": item, "user": user, "importance": importance} return results diff --git a/docs_src/body_multiple_params/tutorial005.py b/docs_src/body_multiple_params/tutorial005.py index 61f1b2917..606d3bbbb 100644 --- a/docs_src/body_multiple_params/tutorial005.py +++ b/docs_src/body_multiple_params/tutorial005.py @@ -12,6 +12,6 @@ class Item(BaseModel): @app.put("/items/{item_id}") -async def update_item(*, item_id: int, item: Item = Body(..., embed=True)): +async def update_item(item_id: int, item: Item = Body(..., embed=True)): results = {"item_id": item_id, "item": item} return results diff --git a/docs_src/body_nested_models/tutorial001.py b/docs_src/body_nested_models/tutorial001.py index 9e0fa4494..56db2a093 100644 --- a/docs_src/body_nested_models/tutorial001.py +++ b/docs_src/body_nested_models/tutorial001.py @@ -13,6 +13,6 @@ class Item(BaseModel): @app.put("/items/{item_id}") -async def update_item(*, item_id: int, item: Item): +async def update_item(item_id: int, item: Item): results = {"item_id": item_id, "item": item} return results diff --git a/docs_src/body_nested_models/tutorial002.py b/docs_src/body_nested_models/tutorial002.py index 8f769279b..db33e483f 100644 --- a/docs_src/body_nested_models/tutorial002.py +++ b/docs_src/body_nested_models/tutorial002.py @@ -15,6 +15,6 @@ class Item(BaseModel): @app.put("/items/{item_id}") -async def update_item(*, item_id: int, item: Item): +async def update_item(item_id: int, item: Item): results = {"item_id": item_id, "item": item} return results diff --git a/docs_src/body_nested_models/tutorial003.py b/docs_src/body_nested_models/tutorial003.py index bb539b127..f65195b62 100644 --- a/docs_src/body_nested_models/tutorial003.py +++ b/docs_src/body_nested_models/tutorial003.py @@ -15,6 +15,6 @@ class Item(BaseModel): @app.put("/items/{item_id}") -async def update_item(*, item_id: int, item: Item): +async def update_item(item_id: int, item: Item): results = {"item_id": item_id, "item": item} return results diff --git a/docs_src/body_nested_models/tutorial004.py b/docs_src/body_nested_models/tutorial004.py index 257928ef3..6c2ca25eb 100644 --- a/docs_src/body_nested_models/tutorial004.py +++ b/docs_src/body_nested_models/tutorial004.py @@ -21,6 +21,6 @@ class Item(BaseModel): @app.put("/items/{item_id}") -async def update_item(*, item_id: int, item: Item): +async def update_item(item_id: int, item: Item): results = {"item_id": item_id, "item": item} return results diff --git a/docs_src/body_nested_models/tutorial005.py b/docs_src/body_nested_models/tutorial005.py index afea77179..d6d9d6479 100644 --- a/docs_src/body_nested_models/tutorial005.py +++ b/docs_src/body_nested_models/tutorial005.py @@ -21,6 +21,6 @@ class Item(BaseModel): @app.put("/items/{item_id}") -async def update_item(*, item_id: int, item: Item): +async def update_item(item_id: int, item: Item): results = {"item_id": item_id, "item": item} return results diff --git a/docs_src/body_nested_models/tutorial006.py b/docs_src/body_nested_models/tutorial006.py index 3d0db6e58..d64668518 100644 --- a/docs_src/body_nested_models/tutorial006.py +++ b/docs_src/body_nested_models/tutorial006.py @@ -21,6 +21,6 @@ class Item(BaseModel): @app.put("/items/{item_id}") -async def update_item(*, item_id: int, item: Item): +async def update_item(item_id: int, item: Item): results = {"item_id": item_id, "item": item} return results diff --git a/docs_src/body_nested_models/tutorial007.py b/docs_src/body_nested_models/tutorial007.py index f13c07ad5..f4b699dbf 100644 --- a/docs_src/body_nested_models/tutorial007.py +++ b/docs_src/body_nested_models/tutorial007.py @@ -28,5 +28,5 @@ class Offer(BaseModel): @app.post("/offers/") -async def create_offer(*, offer: Offer): +async def create_offer(offer: Offer): return offer diff --git a/docs_src/body_nested_models/tutorial008.py b/docs_src/body_nested_models/tutorial008.py index b6f5c0660..3431cc636 100644 --- a/docs_src/body_nested_models/tutorial008.py +++ b/docs_src/body_nested_models/tutorial008.py @@ -12,5 +12,5 @@ class Image(BaseModel): @app.post("/images/multiple/") -async def create_multiple_images(*, images: List[Image]): +async def create_multiple_images(images: List[Image]): return images diff --git a/docs_src/cookie_params/tutorial001.py b/docs_src/cookie_params/tutorial001.py index 5a6fd30fe..bee934b06 100644 --- a/docs_src/cookie_params/tutorial001.py +++ b/docs_src/cookie_params/tutorial001.py @@ -4,5 +4,5 @@ app = FastAPI() @app.get("/items/") -async def read_items(*, ads_id: str = Cookie(None)): +async def read_items(ads_id: str = Cookie(None)): return {"ads_id": ads_id} diff --git a/docs_src/extra_models/tutorial001.py b/docs_src/extra_models/tutorial001.py index 08d3659b0..7ff4bba7e 100644 --- a/docs_src/extra_models/tutorial001.py +++ b/docs_src/extra_models/tutorial001.py @@ -36,6 +36,6 @@ def fake_save_user(user_in: UserIn): @app.post("/user/", response_model=UserOut) -async def create_user(*, user_in: UserIn): +async def create_user(user_in: UserIn): user_saved = fake_save_user(user_in) return user_saved diff --git a/docs_src/extra_models/tutorial002.py b/docs_src/extra_models/tutorial002.py index ab680eca0..030699114 100644 --- a/docs_src/extra_models/tutorial002.py +++ b/docs_src/extra_models/tutorial002.py @@ -34,6 +34,6 @@ def fake_save_user(user_in: UserIn): @app.post("/user/", response_model=UserOut) -async def create_user(*, user_in: UserIn): +async def create_user(user_in: UserIn): user_saved = fake_save_user(user_in) return user_saved diff --git a/docs_src/header_params/tutorial001.py b/docs_src/header_params/tutorial001.py index 69f3dc712..e871de68d 100644 --- a/docs_src/header_params/tutorial001.py +++ b/docs_src/header_params/tutorial001.py @@ -4,5 +4,5 @@ app = FastAPI() @app.get("/items/") -async def read_items(*, user_agent: str = Header(None)): +async def read_items(user_agent: str = Header(None)): return {"User-Agent": user_agent} diff --git a/docs_src/header_params/tutorial002.py b/docs_src/header_params/tutorial002.py index 4edc4b6fd..ba6cef1de 100644 --- a/docs_src/header_params/tutorial002.py +++ b/docs_src/header_params/tutorial002.py @@ -4,5 +4,5 @@ app = FastAPI() @app.get("/items/") -async def read_items(*, strange_header: str = Header(None, convert_underscores=False)): +async def read_items(strange_header: str = Header(None, convert_underscores=False)): return {"strange_header": strange_header} diff --git a/docs_src/path_operation_advanced_configuration/tutorial004.py b/docs_src/path_operation_advanced_configuration/tutorial004.py index 36bf02b11..24be0cb94 100644 --- a/docs_src/path_operation_advanced_configuration/tutorial004.py +++ b/docs_src/path_operation_advanced_configuration/tutorial004.py @@ -15,7 +15,7 @@ class Item(BaseModel): @app.post("/items/", response_model=Item, summary="Create an item") -async def create_item(*, item: Item): +async def create_item(item: Item): """ Create an item with all the information: diff --git a/docs_src/path_operation_configuration/tutorial001.py b/docs_src/path_operation_configuration/tutorial001.py index a60b47fef..77437cd08 100644 --- a/docs_src/path_operation_configuration/tutorial001.py +++ b/docs_src/path_operation_configuration/tutorial001.py @@ -15,5 +15,5 @@ class Item(BaseModel): @app.post("/items/", response_model=Item, status_code=status.HTTP_201_CREATED) -async def create_item(*, item: Item): +async def create_item(item: Item): return item diff --git a/docs_src/path_operation_configuration/tutorial002.py b/docs_src/path_operation_configuration/tutorial002.py index b5d0f12ca..ed29ea014 100644 --- a/docs_src/path_operation_configuration/tutorial002.py +++ b/docs_src/path_operation_configuration/tutorial002.py @@ -15,7 +15,7 @@ class Item(BaseModel): @app.post("/items/", response_model=Item, tags=["items"]) -async def create_item(*, item: Item): +async def create_item(item: Item): return item diff --git a/docs_src/path_operation_configuration/tutorial003.py b/docs_src/path_operation_configuration/tutorial003.py index 106607fd2..4c4b048c7 100644 --- a/docs_src/path_operation_configuration/tutorial003.py +++ b/docs_src/path_operation_configuration/tutorial003.py @@ -20,5 +20,5 @@ class Item(BaseModel): summary="Create an item", description="Create an item with all the information, name, description, price, tax and a set of unique tags", ) -async def create_item(*, item: Item): +async def create_item(item: Item): return item diff --git a/docs_src/path_operation_configuration/tutorial004.py b/docs_src/path_operation_configuration/tutorial004.py index f47d422e0..f9822aae4 100644 --- a/docs_src/path_operation_configuration/tutorial004.py +++ b/docs_src/path_operation_configuration/tutorial004.py @@ -15,7 +15,7 @@ class Item(BaseModel): @app.post("/items/", response_model=Item, summary="Create an item") -async def create_item(*, item: Item): +async def create_item(item: Item): """ Create an item with all the information: diff --git a/docs_src/path_operation_configuration/tutorial005.py b/docs_src/path_operation_configuration/tutorial005.py index 72d02ece3..7ae2acafc 100644 --- a/docs_src/path_operation_configuration/tutorial005.py +++ b/docs_src/path_operation_configuration/tutorial005.py @@ -20,7 +20,7 @@ class Item(BaseModel): summary="Create an item", response_description="The created item", ) -async def create_item(*, item: Item): +async def create_item(item: Item): """ Create an item with all the information: diff --git a/docs_src/request_forms/tutorial001.py b/docs_src/request_forms/tutorial001.py index 0290b644d..c07e22945 100644 --- a/docs_src/request_forms/tutorial001.py +++ b/docs_src/request_forms/tutorial001.py @@ -4,5 +4,5 @@ app = FastAPI() @app.post("/login/") -async def login(*, username: str = Form(...), password: str = Form(...)): +async def login(username: str = Form(...), password: str = Form(...)): return {"username": username} diff --git a/docs_src/response_model/tutorial002.py b/docs_src/response_model/tutorial002.py index b36b2a347..67084b45e 100644 --- a/docs_src/response_model/tutorial002.py +++ b/docs_src/response_model/tutorial002.py @@ -13,5 +13,5 @@ class UserIn(BaseModel): # Don't do this in production! @app.post("/user/", response_model=UserIn) -async def create_user(*, user: UserIn): +async def create_user(user: UserIn): return user diff --git a/docs_src/response_model/tutorial003.py b/docs_src/response_model/tutorial003.py index a73372901..8450723c2 100644 --- a/docs_src/response_model/tutorial003.py +++ b/docs_src/response_model/tutorial003.py @@ -18,5 +18,5 @@ class UserOut(BaseModel): @app.post("/user/", response_model=UserOut) -async def create_user(*, user: UserIn): +async def create_user(user: UserIn): return user diff --git a/docs_src/schema_extra_example/tutorial001.py b/docs_src/schema_extra_example/tutorial001.py index cd4d45f51..59a583750 100644 --- a/docs_src/schema_extra_example/tutorial001.py +++ b/docs_src/schema_extra_example/tutorial001.py @@ -22,6 +22,6 @@ class Item(BaseModel): @app.put("/items/{item_id}") -async def update_item(*, item_id: int, item: Item): +async def update_item(item_id: int, item: Item): results = {"item_id": item_id, "item": item} return results diff --git a/docs_src/schema_extra_example/tutorial002.py b/docs_src/schema_extra_example/tutorial002.py index edf9897d0..0a567bd79 100644 --- a/docs_src/schema_extra_example/tutorial002.py +++ b/docs_src/schema_extra_example/tutorial002.py @@ -12,6 +12,6 @@ class Item(BaseModel): @app.put("/items/{item_id}") -async def update_item(*, item_id: int, item: Item): +async def update_item(item_id: int, item: Item): results = {"item_id": item_id, "item": item} return results diff --git a/docs_src/schema_extra_example/tutorial003.py b/docs_src/schema_extra_example/tutorial003.py index 1165fd7a0..87fbefbb6 100644 --- a/docs_src/schema_extra_example/tutorial003.py +++ b/docs_src/schema_extra_example/tutorial003.py @@ -13,7 +13,6 @@ class Item(BaseModel): @app.put("/items/{item_id}") async def update_item( - *, item_id: int, item: Item = Body( ..., @@ -23,7 +22,7 @@ async def update_item( "price": 35.4, "tax": 3.2, }, - ) + ), ): results = {"item_id": item_id, "item": item} return results diff --git a/docs_src/security/tutorial004.py b/docs_src/security/tutorial004.py index 3c8b6693d..56f0eb0ea 100644 --- a/docs_src/security/tutorial004.py +++ b/docs_src/security/tutorial004.py @@ -75,7 +75,7 @@ def authenticate_user(fake_db, username: str, password: str): return user -def create_access_token(*, data: dict, expires_delta: timedelta = None): +def create_access_token(data: dict, expires_delta: timedelta = None): to_encode = data.copy() if expires_delta: expire = datetime.utcnow() + expires_delta diff --git a/docs_src/security/tutorial005.py b/docs_src/security/tutorial005.py index f43659454..489404d6f 100644 --- a/docs_src/security/tutorial005.py +++ b/docs_src/security/tutorial005.py @@ -91,7 +91,7 @@ def authenticate_user(fake_db, username: str, password: str): return user -def create_access_token(*, data: dict, expires_delta: timedelta = None): +def create_access_token(data: dict, expires_delta: timedelta = None): to_encode = data.copy() if expires_delta: expire = datetime.utcnow() + expires_delta