Skip to content

Commit e182cff

Browse files
author
Harmanpreet Kaur
committed
pylint issues fixed
1 parent 6adecb5 commit e182cff

40 files changed

Lines changed: 268 additions & 223 deletions

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
max-line-length = 88
33
extend-ignore = E501
44
exclude = .venv, frontend
5-
ignore = E203, W503, G004, G200
5+
ignore = E203, W503, G004, G200,B008,ANN,D100,D101,D102,D103,D104,D105,D106,D107

src/backend/api/api_routes.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
"""FastAPI API routes for file processing and conversion"""
1+
"""FastAPI API routes for file processing and conversion."""
22

33
import asyncio
44
import io
55
import zipfile
66

77
from api.auth.auth_utils import get_authenticated_user
88
from api.status_updates import app_connection_manager, close_connection
9+
910
from common.logger.app_logger import AppLogger
1011
from common.services.batch_service import BatchService
12+
1113
from fastapi import (
1214
APIRouter,
1315
File,
@@ -24,13 +26,14 @@
2426
logger = AppLogger("APIRoutes")
2527

2628
# start processing the batch
27-
from sql_agents_start import process_batch_async
29+
from sql_agents_start import process_batch_async # noqa: E402
2830

2931

3032
@router.post("/start-processing")
3133
async def start_processing(request: Request):
3234
"""
33-
Start processing files for a given batch
35+
Start processing files for a given batch.
36+
3437
---
3538
tags:
3639
- File Processing
@@ -50,6 +53,7 @@ async def start_processing(request: Request):
5053
responses:
5154
200:
5255
description: Processing initiated successfully
56+
5357
content:
5458
application/json:
5559
schema:
@@ -61,6 +65,7 @@ async def start_processing(request: Request):
6165
type: string
6266
400:
6367
description: Invalid processing request
68+
6469
500:
6570
description: Internal server error
6671
"""
@@ -89,7 +94,7 @@ async def start_processing(request: Request):
8994
)
9095
async def download_files(batch_id: str):
9196
"""
92-
Download files as ZIP
97+
Download files as ZIP.
9398
9499
---
95100
tags:
@@ -118,7 +123,6 @@ async def download_files(batch_id: str):
118123
type: string
119124
example: Batch not found
120125
"""
121-
122126
# call batch_service get_batch_for_zip to get all files for batch_id
123127
batch_service = BatchService()
124128
await batch_service.initialize_database()
@@ -172,7 +176,7 @@ async def batch_status_updates(
172176
websocket: WebSocket, batch_id: str
173177
): # , request: Request):
174178
"""
175-
WebSocket endpoint for real-time batch status updates
179+
Web-Socket endpoint for real-time batch status updates.
176180
177181
---
178182
tags:
@@ -248,7 +252,7 @@ async def batch_status_updates(
248252
@router.get("/batch-story/{batch_id}")
249253
async def get_batch_status(request: Request, batch_id: str):
250254
"""
251-
Retrieve batch history and file statuses
255+
Retrieve batch history and file statuses.
252256
253257
---
254258
tags:
@@ -371,9 +375,7 @@ async def get_batch_status(request: Request, batch_id: str):
371375

372376
@router.get("/batch-summary/{batch_id}")
373377
async def get_batch_summary(request: Request, batch_id: str):
374-
"""
375-
Retrieve batch summary for a given batch ID.
376-
"""
378+
"""Retrieve batch summary for a given batch ID."""
377379
try:
378380
batch_service = BatchService()
379381
await batch_service.initialize_database()
@@ -404,7 +406,7 @@ async def upload_file(
404406
request: Request, file: UploadFile = File(...), batch_id: str = Form(...)
405407
):
406408
"""
407-
Upload file for conversion
409+
Upload file for conversion.
408410
409411
---
410412
tags:
@@ -634,7 +636,7 @@ async def get_file_details(request: Request, file_id: str):
634636
@router.delete("/delete-batch/{batch_id}")
635637
async def delete_batch_details(request: Request, batch_id: str):
636638
"""
637-
delete batch history using batch_id
639+
Delete batch history using batch_id.
638640
639641
---
640642
tags:
@@ -689,7 +691,7 @@ async def delete_batch_details(request: Request, batch_id: str):
689691
@router.delete("/delete-file/{file_id}")
690692
async def delete_file_details(request: Request, file_id: str):
691693
"""
692-
delete file history using batch_id
694+
Delete file history using batch_id.
693695
694696
---
695697
tags:
@@ -747,7 +749,7 @@ async def delete_file_details(request: Request, file_id: str):
747749
@router.delete("/delete_all")
748750
async def delete_all_details(request: Request):
749751
"""
750-
delete all the history of batches, files and logs
752+
Delete all the history of batches, files and logs.
751753
752754
---
753755
tags:

src/backend/api/auth/auth_utils.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
from fastapi import Request, HTTPException
2-
import logging
31
import base64
42
import json
3+
import logging
54
from typing import Dict
5+
66
from api.auth.sample_user import sample_user
77

8+
from fastapi import HTTPException, Request
9+
810
logger = logging.getLogger(__name__)
911

1012

@@ -26,19 +28,19 @@ def __init__(self, user_details: Dict):
2628

2729

2830
def get_tenant_id(client_principal_b64: str) -> str:
29-
"""Extract tenant ID from base64 encoded client principal"""
31+
"""Extract tenant ID from base64 encoded client principal."""
3032
try:
3133
decoded_bytes = base64.b64decode(client_principal_b64)
3234
decoded_string = decoded_bytes.decode("utf-8")
3335
user_info = json.loads(decoded_string)
3436
return user_info.get("tid", "")
35-
except Exception as ex:
37+
except Exception :
3638
logger.exception("Error decoding client principal")
3739
return ""
3840

3941

4042
def get_authenticated_user(request: Request) -> UserDetails:
41-
"""Get authenticated user details from request headers"""
43+
"""Get authenticated user details from request headers."""
4244
user_object = {}
4345
headers = dict(request.headers)
4446
# Check if we're in production with real headers

src/backend/api/auth/sample_user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
"x-ms-client-principal-idp": "aad",
66
"x-ms-token-aad-id-token": "dev.token",
77
"x-ms-client-principal": "your_base_64_encoded_token"
8-
}
8+
}

src/backend/api/status_updates.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""
22
Holds collection of websocket connections.
3+
34
from clients registering for status updates.
45
These socket references are used to send updates to
56
registered clients from the backend processing code.
@@ -11,6 +12,7 @@
1112
from typing import Dict
1213

1314
from common.models.api import FileProcessUpdate, FileProcessUpdateJSONEncoder
15+
1416
from fastapi import WebSocket
1517

1618
logger = logging.getLogger(__name__)

src/backend/app.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import uvicorn
2-
3-
# Import our route modules
1+
"""Create and configure the FastAPI application."""
42
from api.api_routes import router as backend_router
3+
54
from common.logger.app_logger import AppLogger
5+
66
from dotenv import load_dotenv
7+
78
from fastapi import FastAPI
89
from fastapi.middleware.cors import CORSMiddleware
910

11+
import uvicorn
1012
# from agent_services.agents_routes import router as agents_router
1113

1214
# Load environment variables
@@ -17,9 +19,7 @@
1719

1820

1921
def create_app() -> FastAPI:
20-
"""
21-
Factory function to create and configure the FastAPI application
22-
"""
22+
"""Create and return the FastAPI application instance."""
2323
app = FastAPI(title="Code Gen Accelerator", version="1.0.0")
2424

2525
# Configure CORS
@@ -37,7 +37,7 @@ def create_app() -> FastAPI:
3737

3838
@app.get("/health")
3939
async def health_check():
40-
"""Health check endpoint"""
40+
"""Health check endpoint."""
4141
return {"status": "healthy"}
4242

4343
return app

src/backend/common/config/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22

33
from azure.identity.aio import ClientSecretCredential, DefaultAzureCredential
4+
45
from dotenv import load_dotenv
56

67
load_dotenv()

src/backend/common/database/cosmosdb.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
from datetime import datetime, timezone
2-
from enum import Enum
32
from typing import Dict, List, Optional
43
from uuid import UUID, uuid4
54

65
from azure.cosmos import PartitionKey, exceptions
76
from azure.cosmos.aio import CosmosClient
87
from azure.cosmos.aio._database import DatabaseProxy
98
from azure.cosmos.exceptions import (
10-
CosmosResourceExistsError,
11-
CosmosResourceNotFoundError,
9+
CosmosResourceExistsError
1210
)
11+
1312
from common.database.database_base import DatabaseBase
1413
from common.logger.app_logger import AppLogger
1514
from common.models.api import (
@@ -20,6 +19,7 @@
2019
LogType,
2120
ProcessStatus,
2221
)
22+
2323
from semantic_kernel.contents import AuthorRole
2424

2525

@@ -208,7 +208,7 @@ async def get_batch_files(self, batch_id: str) -> List[Dict]:
208208
raise
209209

210210
async def get_batch_from_id(self, batch_id: str) -> Dict:
211-
"""Retrieve a batch from the database using the batch ID"""
211+
"""Retrieve a batch from the database using the batch ID."""
212212
try:
213213
query = "SELECT * FROM c WHERE c.batch_id = @batch_id"
214214
params = [{"name": "@batch_id", "value": batch_id}]
@@ -225,7 +225,7 @@ async def get_batch_from_id(self, batch_id: str) -> Dict:
225225
raise
226226

227227
async def get_user_batches(self, user_id: str) -> Dict:
228-
"""Retrieve all batches for a given user"""
228+
"""Retrieve all batches for a given user."""
229229
try:
230230
query = "SELECT * FROM c WHERE c.user_id = @user_id"
231231
params = [{"name": "@user_id", "value": user_id}]
@@ -242,7 +242,7 @@ async def get_user_batches(self, user_id: str) -> Dict:
242242
raise
243243

244244
async def get_file_logs(self, file_id: str) -> List[Dict]:
245-
"""Retrieve all logs for a given file"""
245+
"""Retrieve all logs for a given file."""
246246
try:
247247
query = (
248248
"SELECT * FROM c WHERE c.file_id = @file_id ORDER BY c.timestamp DESC"
@@ -322,7 +322,7 @@ async def add_file_log(
322322
agent_type: AgentType,
323323
author_role: AuthorRole,
324324
) -> None:
325-
"""Log a file status update"""
325+
"""Log a file status update."""
326326
try:
327327
log_id = uuid4()
328328
log_entry = FileLog(
@@ -343,7 +343,7 @@ async def add_file_log(
343343
async def update_batch_entry(
344344
self, batch_id: str, user_id: str, status: ProcessStatus, file_count: int
345345
):
346-
"""Update batch status"""
346+
"""Update batch status."""
347347
try:
348348
batch = await self.get_batch(user_id, batch_id)
349349
if not batch:

0 commit comments

Comments
 (0)