Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⬆️ Upgrade configuration for Ruff v0.2.0 #11075

Merged
merged 3 commits into from Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -14,7 +14,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.1.2
rev: v0.2.0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v0.2.2 is out!

Suggested change
rev: v0.2.0
rev: v0.2.2

hooks:
- id: ruff
args:
Expand Down
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)],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a change that was also made in latest Black: psf/black#4164.

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