Coverage for seedboxsync/core/database/models/__init__.py: 100%
14 statements
« prev ^ index » next coverage.py v7.16.1, created at 2026-09-26 17:14 +0000
« prev ^ index » next coverage.py v7.16.1, created at 2026-09-26 17:14 +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 # isort: skip
13from seedboxsync.core.database.models.download import Download
14from seedboxsync.core.database.models.seedboxsync import SeedboxSync
15from seedboxsync.core.database.models.taskstatus import TaskStatus
16from seedboxsync.core.database.models.torrent import Torrent
17from seedboxsync.core.database.models.user import User
19from seedboxsync.core.database.models.apikey import ApiKey # isort: skip
21__all__ = ["ApiKey", "Download", "SeedboxSync", "SeedboxSyncModel", "TaskStatus", "Torrent", "User"]
24def typed_peewee_dicts(query: Any) -> Iterable[dict[str, Any]]:
25 """
26 Cast a Peewee query configured with ``dicts()`` to dictionary rows.
28 This helper works around Peewee's incomplete type annotations, which may
29 still report model instances even when ``dicts()`` is used.
31 Args:
32 query: A Peewee query configured to return rows as dictionaries.
34 Returns:
35 An iterable of dictionary-based query results.
36 """
37 return cast(Iterable[dict[str, Any]], query)
40def typed_peewee_dict(query: Any) -> dict[str, Any]:
41 """
42 Cast a Peewee query configured with ``first()`` (or others) to dictionary rows.
44 This helper works around Peewee's incomplete type annotations, which may
45 still report model instances even when ``first()`` (or others) is used.
47 Args:
48 query: A Peewee query configured to return rows as dictionaries.
50 Returns:
51 An dictionary-based query results.
52 """
53 return cast(dict[str, Any], query)