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:
Elisiário Couto
2025-12-07 11:27:55 +00:00
committed by Elisiário Couto
parent 966440006a
commit 159cba508e
11 changed files with 66 additions and 58 deletions

View File

@@ -8,8 +8,10 @@ from pathlib import Path
from unittest.mock import patch
import pytest
import tomli_w
from fastapi.testclient import TestClient
from leggen.commands.server import create_app
from leggen.utils.config import Config
# Create test config before any imports that might load it
@@ -27,15 +29,12 @@ _config_data = {
"scheduler": {"sync": {"enabled": True, "hour": 3, "minute": 0}},
}
import tomli_w
with open(_test_config_path, "wb") as f:
tomli_w.dump(_config_data, f)
# Set environment variables to point to test config BEFORE importing the app
os.environ["LEGGEN_CONFIG_FILE"] = str(_test_config_path)
from leggen.commands.server import create_app
def pytest_configure(config):
"""Pytest hook called before test collection."""
@@ -114,7 +113,9 @@ def mock_auth_token(temp_config_dir):
def fastapi_app(mock_db_path):
"""Create FastAPI test application."""
# Patch the database path for the app
with patch("leggen.utils.paths.path_manager.get_database_path", return_value=mock_db_path):
with patch(
"leggen.utils.paths.path_manager.get_database_path", return_value=mock_db_path
):
app = create_app()
yield app

View File

@@ -211,10 +211,7 @@ class TestBackupAPI:
assert response.status_code == 200
data = response.json()
assert len(data) == 2
assert (
data[0]["key"]
== "leggen_backups/database_backup_20250101_120000.db"
)
assert data[0]["key"] == "leggen_backups/database_backup_20250101_120000.db"
def test_list_backups_no_config(self, api_client, mock_config):
"""Test backup listing with no configuration."""

View File

@@ -157,7 +157,6 @@ class TestTransactionsAPI:
)
assert response.status_code == 200
data = response.json()
# Verify the database service was called with correct filters
mock_get_transactions.assert_called_once_with(