mirror of
https://github.com/elisiariocouto/leggen.git
synced 2025-12-25 04:49:38 +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
@@ -5,11 +5,19 @@ import random
|
||||
import sqlite3
|
||||
from datetime import datetime, timedelta
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from typing import Any, TypedDict
|
||||
|
||||
import click
|
||||
|
||||
|
||||
class TransactionType(TypedDict):
|
||||
"""Type definition for transaction type configuration."""
|
||||
|
||||
description: str
|
||||
amount_range: tuple[float, float]
|
||||
frequency: float
|
||||
|
||||
|
||||
class SampleDataGenerator:
|
||||
"""Generates realistic sample data for testing Leggen."""
|
||||
|
||||
@@ -42,7 +50,7 @@ class SampleDataGenerator:
|
||||
},
|
||||
]
|
||||
|
||||
self.transaction_types = [
|
||||
self.transaction_types: list[TransactionType] = [
|
||||
{
|
||||
"description": "Grocery Store",
|
||||
"amount_range": (-150, -20),
|
||||
@@ -227,6 +235,8 @@ class SampleDataGenerator:
|
||||
)[0]
|
||||
|
||||
# Generate transaction amount
|
||||
min_amount: float
|
||||
max_amount: float
|
||||
min_amount, max_amount = transaction_type["amount_range"]
|
||||
amount = round(random.uniform(min_amount, max_amount), 2)
|
||||
|
||||
@@ -245,7 +255,7 @@ class SampleDataGenerator:
|
||||
internal_transaction_id = f"int-txn-{random.randint(100000, 999999)}"
|
||||
|
||||
# Create realistic descriptions
|
||||
descriptions = {
|
||||
descriptions: dict[str, list[str]] = {
|
||||
"Grocery Store": [
|
||||
"TESCO",
|
||||
"SAINSBURY'S",
|
||||
@@ -273,7 +283,7 @@ class SampleDataGenerator:
|
||||
"Transfer to Savings": ["SAVINGS TRANSFER", "INVESTMENT TRANSFER"],
|
||||
}
|
||||
|
||||
specific_descriptions = descriptions.get(
|
||||
specific_descriptions: list[str] = descriptions.get(
|
||||
transaction_type["description"], [transaction_type["description"]]
|
||||
)
|
||||
description = random.choice(specific_descriptions)
|
||||
|
||||
Reference in New Issue
Block a user