diff --git a/src/app/api/api_v1/endpoints/login.py b/src/app/api/api_v1/endpoints/login.py index a864c12..204eae8 100644 --- a/src/app/api/api_v1/endpoints/login.py +++ b/src/app/api/api_v1/endpoints/login.py @@ -25,7 +25,7 @@ @router.get("/authorize", summary="Request authorization code through GitHub OAuth app", include_in_schema=False) -async def authorize_github( +def authorize_github( scope: str, redirect_uri: HttpUrl, ) -> RedirectResponse: @@ -40,7 +40,7 @@ async def authorize_github( summary="Request a GitHub token from authorization code", include_in_schema=False, ) -async def request_github_token_from_code( +def request_github_token_from_code( payload: TokenRequest, ) -> GHToken: return gh_client.get_token_from_code(payload.code, payload.redirect_uri) @@ -99,7 +99,7 @@ async def login_with_github_token( @router.get("/validate", status_code=status.HTTP_200_OK, summary="Check token validity") -async def check_token_validity( +def check_token_validity( payload: TokenPayload = Security(get_token_payload, scopes=[UserScope.USER, UserScope.ADMIN]), ) -> TokenPayload: return payload diff --git a/src/app/api/dependencies.py b/src/app/api/dependencies.py index adc2b87..d668028 100644 --- a/src/app/api/dependencies.py +++ b/src/app/api/dependencies.py @@ -30,19 +30,19 @@ ) -async def get_user_crud(session: AsyncSession = Depends(get_session)) -> UserCRUD: +def get_user_crud(session: AsyncSession = Depends(get_session)) -> UserCRUD: return UserCRUD(session=session) -async def get_repo_crud(session: AsyncSession = Depends(get_session)) -> RepositoryCRUD: +def get_repo_crud(session: AsyncSession = Depends(get_session)) -> RepositoryCRUD: return RepositoryCRUD(session=session) -async def get_guideline_crud(session: AsyncSession = Depends(get_session)) -> GuidelineCRUD: +def get_guideline_crud(session: AsyncSession = Depends(get_session)) -> GuidelineCRUD: return GuidelineCRUD(session=session) -async def get_token_payload( +def get_token_payload( security_scopes: SecurityScopes, token: str = Depends(oauth2_scheme), ) -> TokenPayload: @@ -91,5 +91,5 @@ async def get_current_user( users: UserCRUD = Depends(get_user_crud), ) -> User: """Dependency to use as fastapi.security.Security with scopes""" - token_payload = await get_token_payload(security_scopes, token) + token_payload = get_token_payload(security_scopes, token) return cast(User, await users.get(token_payload.user_id, strict=True)) diff --git a/src/app/core/security.py b/src/app/core/security.py index bff3ffb..021a9d5 100644 --- a/src/app/core/security.py +++ b/src/app/core/security.py @@ -16,16 +16,16 @@ pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto") -async def create_access_token(content: Dict[str, Any], expires_minutes: Optional[int] = None) -> str: +def create_access_token(content: Dict[str, Any], expires_minutes: Optional[int] = None) -> str: """Encode content dict using security algorithm, setting expiration.""" expire_delta = timedelta(minutes=expires_minutes or settings.ACCESS_TOKEN_EXPIRE_MINUTES) expire = datetime.utcnow() + expire_delta return jwt.encode({**content, "exp": expire}, settings.SECRET_KEY, algorithm=settings.JWT_ENCODING_ALGORITHM) -async def verify_password(plain_password: str, hashed_password: str) -> bool: +def verify_password(plain_password: str, hashed_password: str) -> bool: return pwd_context.verify(plain_password, hashed_password) -async def hash_password(password: str) -> str: +def hash_password(password: str) -> str: return pwd_context.hash(password) diff --git a/src/app/main.py b/src/app/main.py index 7ac2c8f..a422754 100644 --- a/src/app/main.py +++ b/src/app/main.py @@ -85,7 +85,7 @@ async def add_process_time_header(request: Request, call_next): # Overrides swagger to include favicon @app.get("/docs", include_in_schema=False) -async def swagger_ui_html(): +def swagger_ui_html(): return get_swagger_ui_html( openapi_url=f"{settings.API_V1_STR}/openapi.json", title=settings.PROJECT_NAME, diff --git a/src/tests/conftest.py b/src/tests/conftest.py index 42defd6..6d907bf 100644 --- a/src/tests/conftest.py +++ b/src/tests/conftest.py @@ -103,11 +103,11 @@ async def async_session() -> AsyncSession: await session.rollback() -async def mock_verify_password(plain_password, hashed_password): +def mock_verify_password(plain_password, hashed_password): return hashed_password == f"hashed_{plain_password}" -async def mock_hash_password(password): +def mock_hash_password(password): return f"hashed_{password}" diff --git a/src/tests/test_services.py b/src/tests/test_services.py index ebc3ae6..8635cc7 100644 --- a/src/tests/test_services.py +++ b/src/tests/test_services.py @@ -13,7 +13,7 @@ ], ) @pytest.mark.asyncio() -async def test_githubclient_get_repo(repo_id, status_code, status_detail, expected_name): +def test_githubclient_get_repo(repo_id, status_code, status_detail, expected_name): github_client = GitHubClient() if isinstance(expected_name, str): response = github_client.get_repo(repo_id) @@ -33,7 +33,7 @@ async def test_githubclient_get_repo(repo_id, status_code, status_detail, expect ], ) @pytest.mark.asyncio() -async def test_githubclient_get_user(user_id, status_code, status_detail, expected_name): +def test_githubclient_get_user(user_id, status_code, status_detail, expected_name): github_client = GitHubClient() if isinstance(expected_name, str): response = github_client.get_user(user_id) @@ -53,7 +53,7 @@ async def test_githubclient_get_user(user_id, status_code, status_detail, expect ], ) @pytest.mark.asyncio() -async def test_githubclient_get_readme(repo_name, status_code, status_detail, expected_path): +def test_githubclient_get_readme(repo_name, status_code, status_detail, expected_path): github_client = GitHubClient() if isinstance(expected_path, str): response = github_client.get_readme(repo_name) @@ -74,7 +74,7 @@ async def test_githubclient_get_readme(repo_name, status_code, status_detail, ex ], ) @pytest.mark.asyncio() -async def test_githubclient_get_file(repo_name, file_path, status_code, status_detail): +def test_githubclient_get_file(repo_name, file_path, status_code, status_detail): github_client = GitHubClient() if status_code // 100 == 2: response = github_client.get_file(repo_name, file_path) @@ -95,7 +95,7 @@ async def test_githubclient_get_file(repo_name, file_path, status_code, status_d ], ) @pytest.mark.asyncio() -async def test_githubclient_list_pulls(repo_name, status_code, status_detail): +def test_githubclient_list_pulls(repo_name, status_code, status_detail): github_client = GitHubClient() if status_code // 100 == 2: response = github_client.list_pulls(repo_name) @@ -114,7 +114,7 @@ async def test_githubclient_list_pulls(repo_name, status_code, status_detail): ], ) @pytest.mark.asyncio() -async def test_githubclient_list_comments_from_issue(repo_name, issue_number, status_code, status_detail): +def test_githubclient_list_comments_from_issue(repo_name, issue_number, status_code, status_detail): github_client = GitHubClient() if status_code // 100 == 2: response = github_client.list_comments_from_issue(issue_number, repo_name) @@ -133,7 +133,7 @@ async def test_githubclient_list_comments_from_issue(repo_name, issue_number, st ], ) @pytest.mark.asyncio() -async def test_githubclient_list_reviews_from_pull(repo_name, pull_number, status_code, status_detail): +def test_githubclient_list_reviews_from_pull(repo_name, pull_number, status_code, status_detail): github_client = GitHubClient() if status_code // 100 == 2: response = github_client.list_reviews_from_pull(repo_name, pull_number) @@ -152,7 +152,7 @@ async def test_githubclient_list_reviews_from_pull(repo_name, pull_number, statu ], ) @pytest.mark.asyncio() -async def test_githubclient_list_review_comments_from_pull(repo_name, pull_number, status_code, status_detail): +def test_githubclient_list_review_comments_from_pull(repo_name, pull_number, status_code, status_detail): github_client = GitHubClient() if status_code // 100 == 2: response = github_client.list_review_comments_from_pull(pull_number, repo_name) @@ -171,7 +171,7 @@ async def test_githubclient_list_review_comments_from_pull(repo_name, pull_numbe ], ) @pytest.mark.asyncio() -async def test_githubclient_fetch_reviews_from_repo(repo_name, status_code, status_detail): +def test_githubclient_fetch_reviews_from_repo(repo_name, status_code, status_detail): github_client = GitHubClient() if status_code // 100 == 2: response = github_client.fetch_reviews_from_repo(repo_name, num_pulls=1) @@ -190,7 +190,7 @@ async def test_githubclient_fetch_reviews_from_repo(repo_name, status_code, stat ], ) @pytest.mark.asyncio() -async def test_githubclient_fetch_pull_comments_from_repo(repo_name, status_code, status_detail): +def test_githubclient_fetch_pull_comments_from_repo(repo_name, status_code, status_detail): github_client = GitHubClient() if status_code // 100 == 2: response = github_client.fetch_pull_comments_from_repo(repo_name, num_pulls=1) @@ -221,7 +221,7 @@ async def test_githubclient_fetch_pull_comments_from_repo(repo_name, status_code ], ) @pytest.mark.asyncio() -async def test_githubclient_arrange_in_threads(comments, expected_output): +def test_githubclient_arrange_in_threads(comments, expected_output): assert GitHubClient.arrange_in_threads(comments) == expected_output @@ -232,6 +232,6 @@ async def test_githubclient_arrange_in_threads(comments, expected_output): ], ) @pytest.mark.asyncio() -async def test_execute_in_parallel(func, arr, output): +def test_execute_in_parallel(func, arr, output): assert list(execute_in_parallel(func, arr, num_threads=1)) == output assert list(execute_in_parallel(func, arr, num_threads=2)) == output