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

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.""" 

8 

9from collections.abc import Iterable 

10from typing import Any, cast 

11 

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 

19 

20from seedboxsync.core.database.models.apikey import ApiKey # isort: skip 

21 

22__all__ = ["ApiKey", "Download", "Log", "SeedboxSync", "SeedboxSyncModel", "SeedboxSyncWithStatsModel", "TaskStatus", "Torrent", "User"] 

23 

24 

25def typed_peewee_dicts(query: Any) -> Iterable[dict[str, Any]]: 

26 """ 

27 Cast a Peewee query configured with ``dicts()`` to dictionary rows. 

28 

29 This helper works around Peewee's incomplete type annotations, which may 

30 still report model instances even when ``dicts()`` is used. 

31 

32 Args: 

33 query: A Peewee query configured to return rows as dictionaries. 

34 

35 Returns: 

36 An iterable of dictionary-based query results. 

37 """ 

38 return cast(Iterable[dict[str, Any]], query) 

39 

40 

41def typed_peewee_dict(query: Any) -> dict[str, Any]: 

42 """ 

43 Cast a Peewee query configured with ``first()`` (or others) to dictionary rows. 

44 

45 This helper works around Peewee's incomplete type annotations, which may 

46 still report model instances even when ``first()`` (or others) is used. 

47 

48 Args: 

49 query: A Peewee query configured to return rows as dictionaries. 

50 

51 Returns: 

52 An dictionary-based query results. 

53 """ 

54 return cast(dict[str, Any], query)