refactor: consolidate linting tools into Ruff

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-13 09:10:52 +00:00
parent 071c62c03f
commit 43bc58770d
98 changed files with 739 additions and 1168 deletions
+2 -2
View File
@@ -374,7 +374,7 @@ def reprocess_single_file(request: Request, file_id: int, db: DbSession):
)
logger.info(
f"Reprocessing file: ID={file_record.id}, " f"Filename={file_record.original_filename}, TaskID={task.id}"
f"Reprocessing file: ID={file_record.id}, Filename={file_record.original_filename}, TaskID={task.id}"
)
return {
@@ -645,7 +645,7 @@ def retry_subtask(
upload_task = task_map[subtask_name]
task = upload_task.delay(file_path, file_id)
logger.info(f"Retrying upload subtask: FileID={file_record.id}, " f"Subtask={subtask_name}, TaskID={task.id}")
logger.info(f"Retrying upload subtask: FileID={file_record.id}, Subtask={subtask_name}, TaskID={task.id}")
return {
"status": "success",
+1 -1
View File
@@ -146,7 +146,7 @@ def validate_file_type(content_type: str, filename: str) -> bool:
# Check content type from header
if content_type:
# Handle content-type with charset (e.g., "application/pdf; charset=utf-8")
base_content_type = content_type.split(";")[0].strip().lower()
base_content_type = content_type.split(";", maxsplit=1)[0].strip().lower()
if base_content_type in ALLOWED_MIME_TYPES or base_content_type in IMAGE_MIME_TYPES:
return True
+1 -1
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import os
from typing import Any, List, Optional, Union
from typing import List, Optional, Union
from pydantic import Field, field_validator
from pydantic_settings import BaseSettings, SettingsConfigDict
+1 -2
View File
@@ -5,8 +5,7 @@ import os
from sqlalchemy import create_engine, exc
from sqlalchemy.engine.url import make_url
from sqlalchemy.orm import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm import declarative_base, sessionmaker
from app.config import settings
+1 -3
View File
@@ -340,9 +340,7 @@ def convert_to_pdf(self, file_path: str, original_filename: Optional[str] = None
else:
error_msg = f"Status code: {response.status_code}"
logger.error(
f"[{task_id}] Conversion failed for {file_path}. "
f"{error_msg}, "
f"Response: {response.text[:500]}..."
f"[{task_id}] Conversion failed for {file_path}. {error_msg}, Response: {response.text[:500]}..."
)
log_task_progress(task_id, "call_gotenberg", "failure", error_msg)
log_task_progress(task_id, "convert_to_pdf", "failure", f"Conversion failed: {error_msg}")
+1 -2
View File
@@ -256,8 +256,7 @@ def embed_metadata_into_pdf(self, local_file_path: str, extracted_text: str, met
f"Exception: {str(e)}",
file_id=file_id,
detail=(
f"Failed to embed metadata into {processed_file}.\n"
f"Original file: {original_file}\nException: {str(e)}"
f"Failed to embed metadata into {processed_file}.\nOriginal file: {original_file}\nException: {str(e)}"
),
)
# Clean up temporary file in case of error
+1 -1
View File
@@ -42,7 +42,7 @@ def monitor_stalled_steps():
f"Marked as failed due to timeout."
)
else:
logger.debug(f"[{datetime.utcnow().isoformat()}] " f"No stalled steps found.")
logger.debug(f"[{datetime.utcnow().isoformat()}] No stalled steps found.")
return {"recovered": stalled_count}
@@ -70,13 +70,13 @@ def check_page_rotation(result, filename, task_id=None):
if hasattr(page, "angle"):
rotation_angle = page.angle
if rotation_angle != 0:
logger.info(f"{prefix}Page {i+1} is rotated by {rotation_angle} degrees")
logger.info(f"{prefix}Page {i + 1} is rotated by {rotation_angle} degrees")
# Store page index as integer, not string
rotation_data[i] = rotation_angle
else:
logger.info(f"{prefix}Page {i+1} has no rotation (0 degrees)")
logger.info(f"{prefix}Page {i + 1} has no rotation (0 degrees)")
else:
logger.info(f"{prefix}Page {i+1} rotation information not available")
logger.info(f"{prefix}Page {i + 1} rotation information not available")
return rotation_data
+3 -3
View File
@@ -136,13 +136,13 @@ def rotate_pdf_pages(self, filename: str, extracted_text: str, rotation_data=Non
# pypdf uses clockwise rotation in 90-degree increments
page.rotate(rotation_angle)
logger.info(
f"[{task_id}] Page {page_idx+1} rotated by {rotation_angle}° "
f"[{task_id}] Page {page_idx + 1} rotated by {rotation_angle}° "
f"(from detected {detected_angle}°)"
)
applied_rotations[str(page_idx)] = rotation_angle
else:
logger.info(
f"[{task_id}] Page {page_idx+1} had detected angle {detected_angle}° "
f"[{task_id}] Page {page_idx + 1} had detected angle {detected_angle}° "
"but determined it doesn't need rotation"
)
@@ -154,7 +154,7 @@ def rotate_pdf_pages(self, filename: str, extracted_text: str, rotation_data=Non
if applied_rotations:
logger.info(
f"[{task_id}] Successfully rotated PDF: {filename} with rotations: " f"{json.dumps(applied_rotations)}"
f"[{task_id}] Successfully rotated PDF: {filename} with rotations: {json.dumps(applied_rotations)}"
)
else:
logger.info(
+2 -2
View File
@@ -188,11 +188,11 @@ def upload_large_file(file_path, upload_url):
# 201 = Created (final chunk), 202 = Accepted (more chunks coming)
break
else:
logger.warning(f"Chunk upload failed (attempt {attempt+1}): {response.status_code}")
logger.warning(f"Chunk upload failed (attempt {attempt + 1}): {response.status_code}")
if attempt < max_retries - 1:
time.sleep(retry_delay * (attempt + 1))
except Exception as e:
logger.warning(f"Chunk upload error (attempt {attempt+1}): {str(e)}")
logger.warning(f"Chunk upload error (attempt {attempt + 1}): {str(e)}")
if attempt < max_retries - 1:
time.sleep(retry_delay * (attempt + 1))
@@ -192,9 +192,7 @@ def get_settings_for_display(show_values=False):
[
key
for key in dir(settings)
if not key.startswith("_")
and key not in _PYDANTIC_INTERNALS
and not callable(getattr(settings, key))
if not key.startswith("_") and key not in _PYDANTIC_INTERNALS and not callable(getattr(settings, key))
]
)
-1
View File
@@ -97,7 +97,6 @@ def split_pdf_by_size(pdf_path: str, max_size_bytes: int, output_dir: Optional[s
# If adding this page exceeds the limit (and we have more than 1 page in current chunk)
# save the previous chunk and start a new one
if exceeds_limit and current_page_count > 1:
# Create a new writer without the last page
previous_writer = PdfWriter()
for prev_page_num in range(page_num - current_page_count + 1, page_num):
+1 -1
View File
@@ -310,7 +310,7 @@ def verify_migration(db: Session, file_id: int) -> Dict:
if expected["status"] != actual.status:
result["discrepancies"].append(
f"Step '{step_name}' status mismatch: " f"expected '{expected['status']}', got '{actual.status}'"
f"Step '{step_name}' status mismatch: expected '{expected['status']}', got '{actual.status}'"
)
result["is_valid"] = False
+1 -1
View File
@@ -73,7 +73,7 @@ def mark_stalled_steps_as_failed(
return 0
logger.warning(
f"Found {len(stalled_steps)} stalled step(s) that exceeded " f"{timeout_seconds}s timeout. Marking as failed."
f"Found {len(stalled_steps)} stalled step(s) that exceeded {timeout_seconds}s timeout. Marking as failed."
)
count = 0