mirror of
https://github.com/elisiariocouto/leggen.git
synced 2025-12-23 08:59:34 +00:00
fix: Resolve all lint warnings and type errors across frontend and backend.
Frontend: - Memoize pagination object in TransactionsTable to prevent unnecessary re-renders and fix exhaustive-deps warning - Add optional success and message fields to backup API response types for proper error handling Backend: - Add TypedDict for transaction type configuration to improve type safety in generate_sample_db - Fix unpacking of amount_range with explicit float type hints - Add explicit type hints for descriptions dictionary and specific_descriptions variable - Fix sync endpoint return types: get_sync_status returns SyncStatus and sync_now returns SyncResult - Fix transactions endpoint data type declaration to properly support Union types in PaginatedResponse All checks now pass: - Frontend: npm lint and npm build ✓ - Backend: mypy type checking ✓ - Backend: ruff lint on modified files ✓ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Elisiário Couto
parent
966440006a
commit
159cba508e
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Dict, Generic, List, TypeVar
|
||||
from typing import Generic, List, TypeVar
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
@@ -246,11 +246,6 @@ async def get_account_transactions(
|
||||
offset=offset,
|
||||
)
|
||||
|
||||
# Get total count for pagination info
|
||||
total_transactions = await database_service.get_transaction_count_from_db(
|
||||
account_id=account_id,
|
||||
)
|
||||
|
||||
data: Union[List[TransactionSummary], List[Transaction]]
|
||||
|
||||
if summary_only:
|
||||
@@ -299,9 +294,7 @@ async def get_account_transactions(
|
||||
|
||||
|
||||
@router.put("/accounts/{account_id}")
|
||||
async def update_account_details(
|
||||
account_id: str, update_data: AccountUpdate
|
||||
) -> dict:
|
||||
async def update_account_details(account_id: str, update_data: AccountUpdate) -> dict:
|
||||
"""Update account details (currently only display_name)"""
|
||||
try:
|
||||
# Get current account details
|
||||
|
||||
@@ -129,9 +129,7 @@ async def test_backup_connection(test_request: BackupTest) -> dict:
|
||||
success = await backup_service.test_connection(s3_config)
|
||||
|
||||
if not success:
|
||||
raise HTTPException(
|
||||
status_code=400, detail="S3 connection test failed"
|
||||
)
|
||||
raise HTTPException(status_code=400, detail="S3 connection test failed")
|
||||
|
||||
return {"connected": True}
|
||||
|
||||
@@ -193,9 +191,7 @@ async def backup_operation(operation_request: BackupOperation) -> dict:
|
||||
success = await backup_service.backup_database(database_path)
|
||||
|
||||
if not success:
|
||||
raise HTTPException(
|
||||
status_code=500, detail="Database backup failed"
|
||||
)
|
||||
raise HTTPException(status_code=500, detail="Database backup failed")
|
||||
|
||||
return {"operation": "backup", "completed": True}
|
||||
|
||||
@@ -213,9 +209,7 @@ async def backup_operation(operation_request: BackupOperation) -> dict:
|
||||
)
|
||||
|
||||
if not success:
|
||||
raise HTTPException(
|
||||
status_code=500, detail="Database restore failed"
|
||||
)
|
||||
raise HTTPException(status_code=500, detail="Database restore failed")
|
||||
|
||||
return {"operation": "restore", "completed": True}
|
||||
else:
|
||||
|
||||
@@ -3,7 +3,7 @@ from typing import Optional
|
||||
from fastapi import APIRouter, BackgroundTasks, HTTPException
|
||||
from loguru import logger
|
||||
|
||||
from leggen.api.models.sync import SchedulerConfig, SyncRequest
|
||||
from leggen.api.models.sync import SchedulerConfig, SyncRequest, SyncResult, SyncStatus
|
||||
from leggen.background.scheduler import scheduler
|
||||
from leggen.services.sync_service import SyncService
|
||||
from leggen.utils.config import config
|
||||
@@ -13,7 +13,7 @@ sync_service = SyncService()
|
||||
|
||||
|
||||
@router.get("/sync/status")
|
||||
async def get_sync_status() -> dict:
|
||||
async def get_sync_status() -> SyncStatus:
|
||||
"""Get current sync status"""
|
||||
try:
|
||||
status = await sync_service.get_sync_status()
|
||||
@@ -78,7 +78,7 @@ async def trigger_sync(
|
||||
|
||||
|
||||
@router.post("/sync/now")
|
||||
async def sync_now(sync_request: Optional[SyncRequest] = None) -> dict:
|
||||
async def sync_now(sync_request: Optional[SyncRequest] = None) -> SyncResult:
|
||||
"""Run sync synchronously and return results (slower, for testing)"""
|
||||
try:
|
||||
if sync_request and sync_request.account_ids:
|
||||
|
||||
@@ -64,11 +64,9 @@ async def get_all_transactions(
|
||||
search=search,
|
||||
)
|
||||
|
||||
data: Union[List[TransactionSummary], List[Transaction]]
|
||||
|
||||
if summary_only:
|
||||
# Return simplified transaction summaries
|
||||
data = [
|
||||
data: list[TransactionSummary | Transaction] = [
|
||||
TransactionSummary(
|
||||
transaction_id=txn["transactionId"], # NEW: stable bank-provided ID
|
||||
internal_transaction_id=txn.get("internalTransactionId"),
|
||||
|
||||
Reference in New Issue
Block a user