Coverage for src/typedal/types.py: 100%

21 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-11-01 12:10 +0100

1""" 

2Stuff to make mypy happy. 

3""" 

4from typing import Any, Optional, TypedDict 

5 

6from pydal.objects import Expression as _Expression 

7from pydal.objects import Field as _Field 

8from pydal.objects import Query as _Query 

9 

10 

11class Query(_Query): # type: ignore 

12 """ 

13 Pydal Query object. 

14 

15 Makes mypy happy. 

16 """ 

17 

18 

19class Expression(_Expression): # type: ignore 

20 """ 

21 Pydal Expression object. 

22 

23 Make mypy happy. 

24 """ 

25 

26 

27class Field(_Field): 

28 """ 

29 Pydal Field object. 

30 

31 Make mypy happy. 

32 """ 

33 

34 

35class _Types: 

36 """ 

37 Internal type storage for stuff that mypy otherwise won't understand. 

38 """ 

39 

40 NONETYPE = type(None) 

41 

42 

43class Pagination(TypedDict): 

44 """ 

45 Pagination key of a paginate dict has these items. 

46 """ 

47 

48 total_items: int 

49 current_page: int 

50 per_page: int 

51 total_pages: int 

52 has_next_page: bool 

53 has_prev_page: bool 

54 next_page: Optional[int] 

55 prev_page: Optional[int] 

56 

57 

58class PaginateDict(TypedDict): 

59 """ 

60 Result of PaginatedRows.as_dict(). 

61 """ 

62 

63 data: dict[int, dict[str, Any]] 

64 pagination: Pagination