Fix geo_re_resolve async mocks and mark tasks complete

This commit is contained in:
2026-03-17 18:54:25 +01:00
parent 482399c9e2
commit bdcdd5d672
12 changed files with 208 additions and 136 deletions

View File

@@ -8,12 +8,25 @@ table. All methods are plain async functions that accept a
from __future__ import annotations
import math
from typing import TYPE_CHECKING, Any
from collections.abc import Mapping
from typing import TYPE_CHECKING, TypedDict, cast
if TYPE_CHECKING:
import aiosqlite
class ImportLogRow(TypedDict):
"""Row shape returned by queries on the import_log table."""
id: int
source_id: int | None
source_url: str
timestamp: str
ips_imported: int
ips_skipped: int
errors: str | None
async def add_log(
db: aiosqlite.Connection,
*,
@@ -54,7 +67,7 @@ async def list_logs(
source_id: int | None = None,
page: int = 1,
page_size: int = 50,
) -> tuple[list[dict[str, Any]], int]:
) -> tuple[list[ImportLogRow], int]:
"""Return a paginated list of import log entries.
Args:
@@ -68,8 +81,8 @@ async def list_logs(
*total* is the count of all matching rows (ignoring pagination).
"""
where = ""
params_count: list[Any] = []
params_rows: list[Any] = []
params_count: list[object] = []
params_rows: list[object] = []
if source_id is not None:
where = " WHERE source_id = ?"
@@ -102,7 +115,7 @@ async def list_logs(
return items, total
async def get_last_log(db: aiosqlite.Connection) -> dict[str, Any] | None:
async def get_last_log(db: aiosqlite.Connection) -> ImportLogRow | None:
"""Return the most recent import log entry across all sources.
Args:
@@ -143,13 +156,14 @@ def compute_total_pages(total: int, page_size: int) -> int:
# ---------------------------------------------------------------------------
def _row_to_dict(row: Any) -> dict[str, Any]:
def _row_to_dict(row: object) -> ImportLogRow:
"""Convert an aiosqlite row to a plain Python dict.
Args:
row: An :class:`aiosqlite.Row` or sequence returned by a cursor.
row: An :class:`aiosqlite.Row` or similar mapping returned by a cursor.
Returns:
Dict mapping column names to Python values.
"""
return dict(row)
mapping = cast(Mapping[str, object], row)
return cast(ImportLogRow, dict(mapping))