Coverage for seedboxsync/core/dao/__init__.py: 100%
12 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-26 17:46 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-26 17:46 +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."""
8from collections.abc import Iterable
9from typing import Any, cast
11from seedboxsync.core.dao.model import SeedboxSyncModel # isort: skip
12from seedboxsync.core.dao.download import Download
13from seedboxsync.core.dao.seedboxsync import SeedboxSync
14from seedboxsync.core.dao.taskstatus import TaskStatus
15from seedboxsync.core.dao.torrent import Torrent
17__all__ = ["Download", "SeedboxSync", "SeedboxSyncModel", "TaskStatus", "Torrent"]
20def typed_peewee_dicts(query: Any) -> Iterable[dict[str, Any]]:
21 """
22 Cast a Peewee query configured with ``dicts()`` to dictionary rows.
24 This helper works around Peewee's incomplete type annotations, which may
25 still report model instances even when ``dicts()`` is used.
27 Args:
28 query: A Peewee query configured to return rows as dictionaries.
30 Returns:
31 An iterable of dictionary-based query results.
32 """
33 return cast(Iterable[dict[str, Any]], query)
36def typed_peewee_dict(query: Any) -> dict[str, Any]:
37 """
38 Cast a Peewee query configured with ``first()`` (or others) to dictionary rows.
40 This helper works around Peewee's incomplete type annotations, which may
41 still report model instances even when ``first()`` (or others) is used.
43 Args:
44 query: A Peewee query configured to return rows as dictionaries.
46 Returns:
47 An dictionary-based query results.
48 """
49 return cast(dict[str, Any], query)