Skip to content

Commit

Permalink
Run ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Feb 7, 2024
1 parent 981abc9 commit 312978b
Show file tree
Hide file tree
Showing 41 changed files with 70 additions and 70 deletions.
2 changes: 1 addition & 1 deletion docs_src/dependencies/tutorial005_an.py
Expand Up @@ -21,6 +21,6 @@ def query_or_cookie_extractor(

@app.get("/items/")
async def read_query(
query_or_default: Annotated[str, Depends(query_or_cookie_extractor)]
query_or_default: Annotated[str, Depends(query_or_cookie_extractor)],
):
return {"q_or_cookie": query_or_default}
2 changes: 1 addition & 1 deletion docs_src/dependencies/tutorial005_an_py310.py
Expand Up @@ -20,6 +20,6 @@ def query_or_cookie_extractor(

@app.get("/items/")
async def read_query(
query_or_default: Annotated[str, Depends(query_or_cookie_extractor)]
query_or_default: Annotated[str, Depends(query_or_cookie_extractor)],
):
return {"q_or_cookie": query_or_default}
2 changes: 1 addition & 1 deletion docs_src/dependencies/tutorial005_an_py39.py
Expand Up @@ -20,6 +20,6 @@ def query_or_cookie_extractor(

@app.get("/items/")
async def read_query(
query_or_default: Annotated[str, Depends(query_or_cookie_extractor)]
query_or_default: Annotated[str, Depends(query_or_cookie_extractor)],
):
return {"q_or_cookie": query_or_default}
2 changes: 1 addition & 1 deletion docs_src/header_params/tutorial002.py
Expand Up @@ -7,6 +7,6 @@

@app.get("/items/")
async def read_items(
strange_header: Union[str, None] = Header(default=None, convert_underscores=False)
strange_header: Union[str, None] = Header(default=None, convert_underscores=False),
):
return {"strange_header": strange_header}
2 changes: 1 addition & 1 deletion docs_src/header_params/tutorial002_an_py310.py
Expand Up @@ -7,6 +7,6 @@

@app.get("/items/")
async def read_items(
strange_header: Annotated[str | None, Header(convert_underscores=False)] = None
strange_header: Annotated[str | None, Header(convert_underscores=False)] = None,
):
return {"strange_header": strange_header}
2 changes: 1 addition & 1 deletion docs_src/header_params/tutorial002_py310.py
Expand Up @@ -5,6 +5,6 @@

@app.get("/items/")
async def read_items(
strange_header: str | None = Header(default=None, convert_underscores=False)
strange_header: str | None = Header(default=None, convert_underscores=False),
):
return {"strange_header": strange_header}
2 changes: 1 addition & 1 deletion docs_src/query_params_str_validations/tutorial003.py
Expand Up @@ -7,7 +7,7 @@

@app.get("/items/")
async def read_items(
q: Union[str, None] = Query(default=None, min_length=3, max_length=50)
q: Union[str, None] = Query(default=None, min_length=3, max_length=50),
):
results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
if q:
Expand Down
2 changes: 1 addition & 1 deletion docs_src/query_params_str_validations/tutorial003_an.py
Expand Up @@ -8,7 +8,7 @@

@app.get("/items/")
async def read_items(
q: Annotated[Union[str, None], Query(min_length=3, max_length=50)] = None
q: Annotated[Union[str, None], Query(min_length=3, max_length=50)] = None,
):
results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
if q:
Expand Down
Expand Up @@ -7,7 +7,7 @@

@app.get("/items/")
async def read_items(
q: Annotated[str | None, Query(min_length=3, max_length=50)] = None
q: Annotated[str | None, Query(min_length=3, max_length=50)] = None,
):
results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
if q:
Expand Down
Expand Up @@ -7,7 +7,7 @@

@app.get("/items/")
async def read_items(
q: Annotated[Union[str, None], Query(min_length=3, max_length=50)] = None
q: Annotated[Union[str, None], Query(min_length=3, max_length=50)] = None,
):
results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
if q:
Expand Down
2 changes: 1 addition & 1 deletion docs_src/query_params_str_validations/tutorial007.py
Expand Up @@ -7,7 +7,7 @@

@app.get("/items/")
async def read_items(
q: Union[str, None] = Query(default=None, title="Query string", min_length=3)
q: Union[str, None] = Query(default=None, title="Query string", min_length=3),
):
results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
if q:
Expand Down
2 changes: 1 addition & 1 deletion docs_src/query_params_str_validations/tutorial007_an.py
Expand Up @@ -8,7 +8,7 @@

@app.get("/items/")
async def read_items(
q: Annotated[Union[str, None], Query(title="Query string", min_length=3)] = None
q: Annotated[Union[str, None], Query(title="Query string", min_length=3)] = None,
):
results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
if q:
Expand Down
Expand Up @@ -7,7 +7,7 @@

@app.get("/items/")
async def read_items(
q: Annotated[str | None, Query(title="Query string", min_length=3)] = None
q: Annotated[str | None, Query(title="Query string", min_length=3)] = None,
):
results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
if q:
Expand Down
Expand Up @@ -7,7 +7,7 @@

@app.get("/items/")
async def read_items(
q: Annotated[Union[str, None], Query(title="Query string", min_length=3)] = None
q: Annotated[Union[str, None], Query(title="Query string", min_length=3)] = None,
):
results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
if q:
Expand Down
2 changes: 1 addition & 1 deletion docs_src/query_params_str_validations/tutorial007_py310.py
Expand Up @@ -5,7 +5,7 @@

@app.get("/items/")
async def read_items(
q: str | None = Query(default=None, title="Query string", min_length=3)
q: str | None = Query(default=None, title="Query string", min_length=3),
):
results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
if q:
Expand Down
2 changes: 1 addition & 1 deletion docs_src/query_params_str_validations/tutorial014.py
Expand Up @@ -7,7 +7,7 @@

@app.get("/items/")
async def read_items(
hidden_query: Union[str, None] = Query(default=None, include_in_schema=False)
hidden_query: Union[str, None] = Query(default=None, include_in_schema=False),
):
if hidden_query:
return {"hidden_query": hidden_query}
Expand Down
2 changes: 1 addition & 1 deletion docs_src/query_params_str_validations/tutorial014_an.py
Expand Up @@ -8,7 +8,7 @@

@app.get("/items/")
async def read_items(
hidden_query: Annotated[Union[str, None], Query(include_in_schema=False)] = None
hidden_query: Annotated[Union[str, None], Query(include_in_schema=False)] = None,
):
if hidden_query:
return {"hidden_query": hidden_query}
Expand Down
Expand Up @@ -7,7 +7,7 @@

@app.get("/items/")
async def read_items(
hidden_query: Annotated[str | None, Query(include_in_schema=False)] = None
hidden_query: Annotated[str | None, Query(include_in_schema=False)] = None,
):
if hidden_query:
return {"hidden_query": hidden_query}
Expand Down
Expand Up @@ -7,7 +7,7 @@

@app.get("/items/")
async def read_items(
hidden_query: Annotated[Union[str, None], Query(include_in_schema=False)] = None
hidden_query: Annotated[Union[str, None], Query(include_in_schema=False)] = None,
):
if hidden_query:
return {"hidden_query": hidden_query}
Expand Down
2 changes: 1 addition & 1 deletion docs_src/query_params_str_validations/tutorial014_py310.py
Expand Up @@ -5,7 +5,7 @@

@app.get("/items/")
async def read_items(
hidden_query: str | None = Query(default=None, include_in_schema=False)
hidden_query: str | None = Query(default=None, include_in_schema=False),
):
if hidden_query:
return {"hidden_query": hidden_query}
Expand Down
4 changes: 2 additions & 2 deletions docs_src/security/tutorial003_an.py
Expand Up @@ -68,7 +68,7 @@ async def get_current_user(token: Annotated[str, Depends(oauth2_scheme)]):


async def get_current_active_user(
current_user: Annotated[User, Depends(get_current_user)]
current_user: Annotated[User, Depends(get_current_user)],
):
if current_user.disabled:
raise HTTPException(status_code=400, detail="Inactive user")
Expand All @@ -90,6 +90,6 @@ async def login(form_data: Annotated[OAuth2PasswordRequestForm, Depends()]):

@app.get("/users/me")
async def read_users_me(
current_user: Annotated[User, Depends(get_current_active_user)]
current_user: Annotated[User, Depends(get_current_active_user)],
):
return current_user
4 changes: 2 additions & 2 deletions docs_src/security/tutorial003_an_py310.py
Expand Up @@ -67,7 +67,7 @@ async def get_current_user(token: Annotated[str, Depends(oauth2_scheme)]):


async def get_current_active_user(
current_user: Annotated[User, Depends(get_current_user)]
current_user: Annotated[User, Depends(get_current_user)],
):
if current_user.disabled:
raise HTTPException(status_code=400, detail="Inactive user")
Expand All @@ -89,6 +89,6 @@ async def login(form_data: Annotated[OAuth2PasswordRequestForm, Depends()]):

@app.get("/users/me")
async def read_users_me(
current_user: Annotated[User, Depends(get_current_active_user)]
current_user: Annotated[User, Depends(get_current_active_user)],
):
return current_user
4 changes: 2 additions & 2 deletions docs_src/security/tutorial003_an_py39.py
Expand Up @@ -67,7 +67,7 @@ async def get_current_user(token: Annotated[str, Depends(oauth2_scheme)]):


async def get_current_active_user(
current_user: Annotated[User, Depends(get_current_user)]
current_user: Annotated[User, Depends(get_current_user)],
):
if current_user.disabled:
raise HTTPException(status_code=400, detail="Inactive user")
Expand All @@ -89,6 +89,6 @@ async def login(form_data: Annotated[OAuth2PasswordRequestForm, Depends()]):

@app.get("/users/me")
async def read_users_me(
current_user: Annotated[User, Depends(get_current_active_user)]
current_user: Annotated[User, Depends(get_current_active_user)],
):
return current_user
2 changes: 1 addition & 1 deletion docs_src/security/tutorial004.py
Expand Up @@ -114,7 +114,7 @@ async def get_current_active_user(current_user: User = Depends(get_current_user)

@app.post("/token")
async def login_for_access_token(
form_data: OAuth2PasswordRequestForm = Depends()
form_data: OAuth2PasswordRequestForm = Depends(),
) -> Token:
user = authenticate_user(fake_users_db, form_data.username, form_data.password)
if not user:
Expand Down
8 changes: 4 additions & 4 deletions docs_src/security/tutorial004_an.py
Expand Up @@ -108,7 +108,7 @@ async def get_current_user(token: Annotated[str, Depends(oauth2_scheme)]):


async def get_current_active_user(
current_user: Annotated[User, Depends(get_current_user)]
current_user: Annotated[User, Depends(get_current_user)],
):
if current_user.disabled:
raise HTTPException(status_code=400, detail="Inactive user")
Expand All @@ -117,7 +117,7 @@ async def get_current_active_user(

@app.post("/token")
async def login_for_access_token(
form_data: Annotated[OAuth2PasswordRequestForm, Depends()]
form_data: Annotated[OAuth2PasswordRequestForm, Depends()],
) -> Token:
user = authenticate_user(fake_users_db, form_data.username, form_data.password)
if not user:
Expand All @@ -135,13 +135,13 @@ async def login_for_access_token(

@app.get("/users/me/", response_model=User)
async def read_users_me(
current_user: Annotated[User, Depends(get_current_active_user)]
current_user: Annotated[User, Depends(get_current_active_user)],
):
return current_user


@app.get("/users/me/items/")
async def read_own_items(
current_user: Annotated[User, Depends(get_current_active_user)]
current_user: Annotated[User, Depends(get_current_active_user)],
):
return [{"item_id": "Foo", "owner": current_user.username}]
8 changes: 4 additions & 4 deletions docs_src/security/tutorial004_an_py310.py
Expand Up @@ -107,7 +107,7 @@ async def get_current_user(token: Annotated[str, Depends(oauth2_scheme)]):


async def get_current_active_user(
current_user: Annotated[User, Depends(get_current_user)]
current_user: Annotated[User, Depends(get_current_user)],
):
if current_user.disabled:
raise HTTPException(status_code=400, detail="Inactive user")
Expand All @@ -116,7 +116,7 @@ async def get_current_active_user(

@app.post("/token")
async def login_for_access_token(
form_data: Annotated[OAuth2PasswordRequestForm, Depends()]
form_data: Annotated[OAuth2PasswordRequestForm, Depends()],
) -> Token:
user = authenticate_user(fake_users_db, form_data.username, form_data.password)
if not user:
Expand All @@ -134,13 +134,13 @@ async def login_for_access_token(

@app.get("/users/me/", response_model=User)
async def read_users_me(
current_user: Annotated[User, Depends(get_current_active_user)]
current_user: Annotated[User, Depends(get_current_active_user)],
):
return current_user


@app.get("/users/me/items/")
async def read_own_items(
current_user: Annotated[User, Depends(get_current_active_user)]
current_user: Annotated[User, Depends(get_current_active_user)],
):
return [{"item_id": "Foo", "owner": current_user.username}]
8 changes: 4 additions & 4 deletions docs_src/security/tutorial004_an_py39.py
Expand Up @@ -107,7 +107,7 @@ async def get_current_user(token: Annotated[str, Depends(oauth2_scheme)]):


async def get_current_active_user(
current_user: Annotated[User, Depends(get_current_user)]
current_user: Annotated[User, Depends(get_current_user)],
):
if current_user.disabled:
raise HTTPException(status_code=400, detail="Inactive user")
Expand All @@ -116,7 +116,7 @@ async def get_current_active_user(

@app.post("/token")
async def login_for_access_token(
form_data: Annotated[OAuth2PasswordRequestForm, Depends()]
form_data: Annotated[OAuth2PasswordRequestForm, Depends()],
) -> Token:
user = authenticate_user(fake_users_db, form_data.username, form_data.password)
if not user:
Expand All @@ -134,13 +134,13 @@ async def login_for_access_token(

@app.get("/users/me/", response_model=User)
async def read_users_me(
current_user: Annotated[User, Depends(get_current_active_user)]
current_user: Annotated[User, Depends(get_current_active_user)],
):
return current_user


@app.get("/users/me/items/")
async def read_own_items(
current_user: Annotated[User, Depends(get_current_active_user)]
current_user: Annotated[User, Depends(get_current_active_user)],
):
return [{"item_id": "Foo", "owner": current_user.username}]
2 changes: 1 addition & 1 deletion docs_src/security/tutorial004_py310.py
Expand Up @@ -113,7 +113,7 @@ async def get_current_active_user(current_user: User = Depends(get_current_user)

@app.post("/token")
async def login_for_access_token(
form_data: OAuth2PasswordRequestForm = Depends()
form_data: OAuth2PasswordRequestForm = Depends(),
) -> Token:
user = authenticate_user(fake_users_db, form_data.username, form_data.password)
if not user:
Expand Down
6 changes: 3 additions & 3 deletions docs_src/security/tutorial005.py
Expand Up @@ -136,7 +136,7 @@ async def get_current_user(


async def get_current_active_user(
current_user: User = Security(get_current_user, scopes=["me"])
current_user: User = Security(get_current_user, scopes=["me"]),
):
if current_user.disabled:
raise HTTPException(status_code=400, detail="Inactive user")
Expand All @@ -145,7 +145,7 @@ async def get_current_active_user(

@app.post("/token")
async def login_for_access_token(
form_data: OAuth2PasswordRequestForm = Depends()
form_data: OAuth2PasswordRequestForm = Depends(),
) -> Token:
user = authenticate_user(fake_users_db, form_data.username, form_data.password)
if not user:
Expand All @@ -165,7 +165,7 @@ async def read_users_me(current_user: User = Depends(get_current_active_user)):

@app.get("/users/me/items/")
async def read_own_items(
current_user: User = Security(get_current_active_user, scopes=["items"])
current_user: User = Security(get_current_active_user, scopes=["items"]),
):
return [{"item_id": "Foo", "owner": current_user.username}]

Expand Down

0 comments on commit 312978b

Please sign in to comment.