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

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 

10 

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 

16 

17__all__ = ["Download", "SeedboxSync", "SeedboxSyncModel", "TaskStatus", "Torrent"] 

18 

19 

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

21 """ 

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

23 

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

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

26 

27 Args: 

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

29 

30 Returns: 

31 An iterable of dictionary-based query results. 

32 """ 

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

34 

35 

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

37 """ 

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

39 

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

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

42 

43 Args: 

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

45 

46 Returns: 

47 An dictionary-based query results. 

48 """ 

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