mirror of
https://github.com/fastapi-practices/fastapi-best-architecture.git
synced 2026-09-21 21:15:13 +00:00
Update the ruff rules and format the code (#846)
* Update the ruff rules and format the code * Update the per-file-ignores * Update the ci * Update rules * Fix codes * Fix pagination * Update rules
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import APIRouter, BackgroundTasks, Depends, Request, Response
|
||||
from fastapi_limiter.depends import RateLimiter
|
||||
from fastapi_oauth20 import FastAPIOAuth20, GitHubOAuth20
|
||||
@@ -27,11 +27,14 @@ async def get_github_oauth2_url(request: Request) -> ResponseSchemaModel[str]:
|
||||
description='Github 授权后,自动重定向到当前地址并获取用户信息,通过用户信息自动创建系统用户',
|
||||
dependencies=[Depends(RateLimiter(times=5, minutes=1))],
|
||||
)
|
||||
async def github_oauth2_callback(
|
||||
async def github_oauth2_callback( # noqa: ANN201
|
||||
request: Request,
|
||||
response: Response,
|
||||
background_tasks: BackgroundTasks,
|
||||
oauth2: FastAPIOAuth20 = Depends(FastAPIOAuth20(github_client, redirect_route_name='github_oauth2_callback')),
|
||||
oauth2: Annotated[
|
||||
FastAPIOAuth20,
|
||||
Depends(FastAPIOAuth20(github_client, redirect_route_name='github_oauth2_callback')),
|
||||
],
|
||||
):
|
||||
token, _state = oauth2
|
||||
access_token = token['access_token']
|
||||
@@ -44,5 +47,5 @@ async def github_oauth2_callback(
|
||||
social=UserSocialType.github,
|
||||
)
|
||||
return RedirectResponse(
|
||||
url=f'{settings.OAUTH2_FRONTEND_REDIRECT_URI}?access_token={data.access_token}&session_uuid={data.session_uuid}'
|
||||
url=f'{settings.OAUTH2_FRONTEND_REDIRECT_URI}?access_token={data.access_token}&session_uuid={data.session_uuid}',
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user