📝 Remove *, from functions where it's not needed #1234 (#1239)

* 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 <tiangolo@gmail.com>
This commit is contained in:
Pankaj Giri 2020-06-13 01:11:44 +05:30 committed by GitHub
parent 1b2a7546af
commit 7e2518350a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 32 additions and 33 deletions

View File

@ -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!}
```

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -28,5 +28,5 @@ class Offer(BaseModel):
@app.post("/offers/")
async def create_offer(*, offer: Offer):
async def create_offer(offer: Offer):
return offer

View File

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

View File

@ -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}

View File

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

View File

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

View File

@ -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}

View File

@ -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}

View File

@ -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:

View File

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

View File

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

View File

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

View File

@ -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:

View File

@ -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:

View File

@ -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}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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