Coverage for seedboxsync/core/database/models/__init__.py: 100%
15 statements
« prev ^ index » next coverage.py v7.17.0, created at 2026-10-31 17:10 +0000
« prev ^ index » next coverage.py v7.17.0, created at 2026-10-31 17:10 +0000
1#
2# Copyright (C) 2015-2026 Guillaume Kulakowski <guillaume@kulakowski.fr>
3#
4# For the full copyright and license information, please view the LICENSE
5# file that was distributed with this source code.
6#
7"""DAO package with all Peewee models."""
9from collections.abc import Iterable
10from typing import Any, cast
12from seedboxsync.core.database.models.model import SeedboxSyncModel, SeedboxSyncWithStatsModel # isort: skip
13from seedboxsync.core.database.models.download import Download
14from seedboxsync.core.database.models.log import Log
15from seedboxsync.core.database.models.seedboxsync import SeedboxSync
16from seedboxsync.core.database.models.taskstatus import TaskStatus
17from seedboxsync.core.database.models.torrent import Torrent
18from seedboxsync.core.database.models.user import User
20from seedboxsync.core.database.models.apikey import ApiKey # isort: skip
22__all__ = ["ApiKey", "Download", "Log", "SeedboxSync", "SeedboxSyncModel", "SeedboxSyncWithStatsModel", "TaskStatus", "Torrent", "User"]
25def typed_peewee_dicts(query: Any) -> Iterable[dict[str, Any]]:
26 """
27 Cast a Peewee query configured with ``dicts()`` to dictionary rows.
29 This helper works around Peewee's incomplete type annotations, which may
30 still report model instances even when ``dicts()`` is used.
32 Args:
33 query: A Peewee query configured to return rows as dictionaries.
35 Returns:
36 An iterable of dictionary-based query results.
37 """
38 return cast(Iterable[dict[str, Any]], query)
41def typed_peewee_dict(query: Any) -> dict[str, Any]:
42 """
43 Cast a Peewee query configured with ``first()`` (or others) to dictionary rows.
45 This helper works around Peewee's incomplete type annotations, which may
46 still report model instances even when ``first()`` (or others) is used.
48 Args:
49 query: A Peewee query configured to return rows as dictionaries.
51 Returns:
52 An dictionary-based query results.
53 """
54 return cast(dict[str, Any], query)